PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 3.1.0
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v3.1.0
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 1 year ago class-email-signup.php 1 year ago class-polylang.php 1 year ago class-review-box.php 1 year ago class-upgrade-box.php 1 year ago class-wpml.php 1 year ago folders.class.php 1 year ago form.class.php 1 year ago form.fields.php 1 year ago import.export.class.php 1 year ago media.replace.php 1 year ago notifications.class.php 1 year ago plugins.class.php 1 year ago svg.class.php 1 year ago tree.class.php 1 year ago
folders.class.php
7568 lines
1 <?php
2 /**
3 * Class Folders Main
4 *
5 * @author : Premio <contact@premio.io>
6 * @license : GPL2
7 * */
8
9 if (! defined('ABSPATH')) {
10 exit;
11 }
12
13 // Free/Pro Class name change
14 class WCP_Folders
15 {
16
17 /**
18 * Instance of Class
19 *
20 * @var object $instance Instance of Class
21 * @since 1.0.0
22 * @access public
23 */
24 private static $instance;
25
26 /**
27 * License key data
28 *
29 * @var array $license_key_data License key data
30 * @since 1.0.0
31 * @access public
32 */
33 private static $license_key_data = null;
34
35 /**
36 * Folders data
37 *
38 * @var object $folders Folders data
39 * @since 1.0.0
40 * @access public
41 */
42 private static $folders;
43
44 /**
45 * Total number of folders
46 *
47 * @var integer $tlfs total number of folders
48 * @since 1.0.0
49 * @access public
50 */
51 public $tlfs = 0;
52
53 /**
54 * Collection on post ids
55 *
56 * @var array $postIds collection on post ids
57 * @since 1.0.0
58 * @access public
59 */
60 private static $postIds;
61
62 /**
63 * Folders Settings
64 *
65 * @var array $folderSettings Folders Settings
66 * @since 1.0.0
67 * @access public
68 */
69 private static $folderSettings = false;
70
71
72 /**
73 * Folders Settings
74 *
75 * @var array $folders_settings Folders Settings
76 * @since 1.0.0
77 * @access public
78 */
79 var $folders_settings = false;
80
81
82 /**
83 * Define the core functionality of the import data functionality.
84 *
85 * Add/Update folders settings
86 * Add/Update/Remove/List of folders
87 * Add/Update/Remove/List posts to folders
88 * Mark/Unmark folders
89 * Make Sticky/Unsticky folders
90 * Add content to folders
91 * Update folder sidebar width
92 * Filter taxonomies for folders
93 * Show drag buttons to post/page table
94 *
95 * @since 1.0.0
96 */
97 public function __construct()
98 {
99
100 spl_autoload_register([$this, 'autoload']);
101 add_action('init', [$this, 'create_folder_terms'], 15);
102 add_action('admin_init', [$this, 'folders_register_settings']);
103 add_action('admin_menu', [$this, 'admin_menu'], 10000);
104 add_action('admin_enqueue_scripts', [$this, 'folders_admin_styles']);
105 add_action('admin_enqueue_scripts', [$this, 'folders_admin_scripts']);
106 add_filter('plugin_action_links_'.WCP_FOLDERS_PLUGIN_BASE, [$this, 'plugin_action_links']);
107 add_action('admin_footer', [$this, 'admin_footer']);
108
109 add_action('parse_tax_query', [$this, 'taxonomy_archive_exclude_children']);
110 add_action('admin_footer', [$this, 'admin_footer_for_media']);
111
112 // Save Data
113 add_action('wp_ajax_wcp_add_new_folder', [$this, 'wcp_add_new_folder']);
114 // Update Data
115 add_action('wp_ajax_wcp_update_folder', [$this, 'wcp_update_folder']);
116 // Remove Data
117 add_action('wp_ajax_wcp_remove_folder', [$this, 'wcp_remove_folder']);
118 // Remove Multple Folder
119 add_action('wp_ajax_wcp_remove_muliple_folder', [$this, 'remove_muliple_folder']);
120 // Save State Data
121 add_action('wp_ajax_save_wcp_folder_state', [$this, 'save_wcp_folder_state']);
122 // Save State Data
123 add_action('wp_ajax_wcp_save_parent_data', [$this, 'wcp_save_parent_data']);
124 // Update Parent Data
125 add_action('wp_ajax_wcp_update_parent_information', [$this, 'wcp_update_parent_information']);
126 // Update Parent Data
127 add_action('wp_ajax_wcp_save_folder_order', [$this, 'wcp_save_folder_order']);
128 // Update Parent Data
129 add_action('wp_ajax_wcp_mark_un_mark_folder', [$this, 'wcp_mark_un_mark_folder']);
130 // Update Parent Data
131 add_action('wp_ajax_wcp_make_sticky_folder', [$this, 'wcp_make_sticky_folder']);
132 // Update Parent Data
133 add_action('wp_ajax_wcp_change_post_folder', [$this, 'wcp_change_post_folder']);
134 // Update Parent Data
135 add_action('wp_ajax_wcp_change_multiple_post_folder', [$this, 'wcp_change_multiple_post_folder']);
136 // Update width Data
137 add_action('wp_ajax_wcp_change_post_width', [$this, 'wcp_change_post_width']);
138 // Update width Data
139 add_action('wp_ajax_wcp_change_folder_display_status', [$this, 'wcp_change_folder_display_status']);
140 // Update width Data
141 add_action('wp_ajax_wcp_change_all_status', [$this, 'wcp_change_all_status']);
142 // Update width Data
143 add_action('wp_ajax_save_folder_last_status', [$this, 'save_folder_last_status']);
144 // Update width Data
145 add_action('wp_ajax_wcp_folders_by_order', [$this, 'wcp_folders_by_order']);
146 // Update width Data
147 add_action('wp_ajax_wcp_remove_all_folders_data', [$this, 'remove_all_folders_data']);
148 // Update folders Status
149 add_action('wp_ajax_wcp_update_folders_uninstall_status', [$this, 'update_folders_uninstall_status']);
150 // Undo Functionality
151 add_action('wp_ajax_wcp_undo_folder_changes', [$this, 'wcp_undo_folder_changes']);
152 self::$folders = 10;
153
154 // Send message on plugin deactivate
155 add_action('wp_ajax_folder_plugin_deactivate', [ $this, 'folder_plugin_deactivate' ]);
156 // Update Parent Data
157 add_action('wp_ajax_wcp_remove_post_folder', [$this, 'wcp_remove_post_folder']);
158 // Change folder color
159 add_action('wp_ajax_wcp_change_color_folder', [$this, 'wcp_change_color_folder']);
160 // Send message on owner
161 add_action('wp_ajax_wcp_folder_send_message_to_owner', [ $this, 'wcp_folder_send_message_to_owner' ]);
162 // Get default list
163 add_action('wp_ajax_premio_check_for_other_folders', [$this, 'premio_check_for_other_folders']);
164 // Send message on owner
165 add_action('wp_ajax_wcp_get_default_list', [ $this, 'wcp_get_default_list' ]);
166 // Get default list
167 add_action('wp_ajax_get_folders_default_list', [ $this, 'get_folders_default_list' ]);
168 // Auto select folder for new page, post
169 add_action('new_to_auto-draft', [$this, 'new_to_auto_draft'], 10);
170 // for media
171 add_action('restrict_manage_posts', [$this, 'output_list_table_filters'], 10, 2);
172 add_filter('pre_get_posts', [$this, 'filter_attachments_list']);
173 add_action('wp_enqueue_media', [$this, 'output_backbone_view_filters']);
174 add_filter('ajax_query_attachments_args', [$this, 'filter_attachments_grid']);
175 add_filter('add_attachment', [$this, 'save_media_terms']);
176
177 // to filter un assigned items
178 add_filter('pre_get_posts', [$this, 'filter_record_list']);
179 add_filter('pre-upload-ui', [$this, 'show_dropdown_on_media_screen']);
180 add_action('add_attachment', [$this, 'add_attachment_category']);
181
182 $options = get_option("folders_settings");
183
184 $options = is_array($options) ? $options : [];
185
186 if (in_array("post", $options)) {
187 add_filter('manage_posts_columns', [$this, 'wcp_manage_columns_head']);
188 add_action('manage_posts_custom_column', [$this, 'wcp_manage_columns_content'], 10, 2);
189 add_filter('bulk_actions-edit-post', [$this, 'custom_bulk_action' ]);
190 }
191
192 if (in_array("page", $options)) {
193 add_filter('manage_page_posts_columns', [$this, 'wcp_manage_columns_head']);
194 add_action('manage_page_posts_custom_column', [$this, 'wcp_manage_columns_content'], 10, 2);
195 add_filter('bulk_actions-edit-page', [$this, 'custom_bulk_action' ]);
196 }
197
198 if (in_array("attachment", $options)) {
199 add_filter('manage_media_columns', [$this, 'wcp_manage_columns_head']);
200 add_action('manage_media_custom_column', [$this, 'wcp_manage_columns_content'], 10, 2);
201 // add_filter('bulk_actions-edit-media', array($this, 'custom_bulk_action' ));
202 }
203
204 foreach ($options as $option) {
205 if ($option != "post" && $option != "page" && $option != "attachment") {
206 add_filter('manage_edit-'.$option.'_columns', [$this, 'wcp_manage_columns_head'], 99999);
207 add_action('manage_'.$option.'_posts_custom_column', [$this, 'wcp_manage_columns_content'], 2, 2);
208 add_filter('bulk_actions-edit-'.$option, [$this, 'custom_bulk_action' ]);
209 }
210 }
211
212 // check for default folders
213 add_filter('pre_get_posts', [$this, 'check_for_default_folders']);
214 add_filter('folders_count_where_query', [$this, 'folders_count_where_query']);
215 add_filter('folders_count_join_query', [$this, 'folders_count_join_query']);
216
217 // add_action("wp_ajax_folder_update_status", [$this, 'folder_update_status']);
218
219 // load language files
220 add_action('plugins_loaded', [ $this, 'folders_text' ]);
221
222 add_action("wp_ajax_folder_update_popup_status", [$this, 'folder_update_popup_status']);
223
224 add_action("wp_ajax_premio_hide_child_popup", [$this, 'premio_hide_child_popup']);
225
226 add_action("wp_ajax_wcp_update_folders_import_status", [$this, 'update_folders_import_status']);
227
228 add_filter('get_terms', [ $this, 'get_terms_filter_without_trash'], 10, 3);
229
230 add_filter('mla_media_modal_query_final_terms', [ $this, 'media_modal_query_final_terms'], 10, 3);
231
232 // reset count when post/page updated
233 add_action('deleted_term_relationships', [$this, 'update_folder_term_relationships'], 10, 3);
234
235 add_action('added_term_relationship', [$this, 'update_folder_new_term_relationships'], 10, 3);
236
237 add_action('set_object_terms', [$this, 'set_object_terms_for_folders'], 10, 6);
238
239 /*
240 * To Remove Attachment
241 * */
242
243 add_action('wp_trash_post', [$this, "wcp_delete_post"]);
244 add_action('before_delete_post', [$this, "wcp_delete_post"]);
245 add_action('save_post', [$this, "save_post"], 10, 3);
246
247 /*
248 * Hide Folder CTA
249 * */
250 add_action('wp_ajax_hide_folders_cta', [$this, 'hide_folders_cta']);
251 add_action('wp_ajax_hide_folder_color_pop_up', [$this, 'hide_folder_color_pop_up']);
252
253 add_action("manage_posts_extra_tablenav", [$this, "manage_posts_extra_fields"]);
254
255 /* Mailpoet Whitelist JS/CSS */
256 add_filter("mailpoet_conflict_resolver_whitelist_style", [$this, 'mailpoet_conflict_whitelist_style']);
257 add_filter("mailpoet_conflict_resolver_whitelist_script", [$this, 'mailpoet_conflict_whitelist_script']);
258
259 add_action("admin_head", [$this, "admin_head"]);
260
261 // Remove Media Library for Dokan for frontend users
262 add_filter("check_media_status_for_folders", [$this, "check_media_status_for_folders"]);
263
264 add_action("admin_init", [$this, "check_for_signup_status"]);
265 add_action("admin_init", [$this, "change_menu_text"]);
266 add_action( 'admin_init', [$this, 'process_request'], 1 );
267
268 }//end __construct()
269
270 public function process_request()
271 {
272 // Check for filter: Remove if filter by folders
273 global $_REQUEST;
274 $isMediaFilter = isset($_REQUEST['action']) && $_REQUEST['action'] == 'query-attachments';
275 $hasMediaFilter = isset($_REQUEST['query']['media_folder']) && !empty($_REQUEST['query']['media_folder']);
276 if($isMediaFilter && $hasMediaFilter && defined('MLA_PLUGIN_PATH')) {
277 if(isset($_REQUEST['query']['s']) && is_array($_REQUEST['query']['s'])) {
278 unset($_REQUEST['query']['s']);
279 }
280 remove_action( 'admin_init', 'MLAModal_Ajax::mla_admin_init_action' );
281 }
282 }
283
284 public function change_menu_text()
285 {
286 global $submenu;
287 if(isset($submenu['wcp_folders_settings'])) {
288 $totalItems = count($submenu['wcp_folders_settings'])-1;
289 if(isset($submenu['wcp_folders_settings'][$totalItems][0])) {
290 $submenu['wcp_folders_settings'][$totalItems][0] = '<span><svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
291 <path d="M13.0518 4.01946C12.9266 3.91499 12.7747 3.84781 12.6132 3.82557C12.4517 3.80333 12.2872 3.82693 12.1385 3.89367L9.3713 5.12414L7.76349 2.22571C7.68664 2.09039 7.5753 1.97785 7.44081 1.89956C7.30632 1.82127 7.15348 1.78003 6.99786 1.78003C6.84224 1.78003 6.6894 1.82127 6.55491 1.89956C6.42042 1.97785 6.30908 2.09039 6.23224 2.22571L4.62442 5.12414L1.85724 3.89367C1.70822 3.82703 1.54352 3.8034 1.38178 3.82545C1.22003 3.84751 1.06768 3.91437 0.941941 4.01849C0.816207 4.1226 0.722106 4.25982 0.670275 4.41461C0.618444 4.56941 0.610951 4.73562 0.648642 4.89446L2.0377 10.8171C2.06427 10.9318 2.11383 11.0399 2.18339 11.1348C2.25295 11.2297 2.34107 11.3096 2.44239 11.3695C2.57957 11.4516 2.73642 11.495 2.8963 11.4952C2.97402 11.4951 3.05133 11.484 3.12599 11.4624C5.65792 10.7624 8.33233 10.7624 10.8643 11.4624C11.0955 11.5232 11.3413 11.4898 11.5479 11.3695C11.6498 11.3103 11.7384 11.2307 11.8081 11.1357C11.8777 11.0406 11.9269 10.9321 11.9525 10.8171L13.3471 4.89446C13.3843 4.73558 13.3764 4.56945 13.3243 4.41482C13.2721 4.2602 13.1777 4.12326 13.0518 4.01946V4.01946Z" fill="white"/>
292 </svg></span> '.esc_html__( 'Upgrade to Pro' , 'folders');
293 }
294 }
295 }
296
297 function check_for_signup_status() {
298 if(!defined("DOING_AJAX")) {
299 $option = get_option("folder_redirect_status");
300 if ($option == 1) {
301 update_option("folder_redirect_status", 2);
302 wp_redirect(admin_url("admin.php?page=wcp_folders_settings"));
303 exit;
304 }
305
306 $page = filter_input(INPUT_GET, 'page');
307 if ($page == "recommended-folder-plugins" || $page == "folders-upgrade-to-pro") {
308 $is_shown = get_option("folder_update_message");
309 if ($is_shown === false && FOLDER_SIGNUP_CLASS::check_modal_status()) {
310 wp_redirect(admin_url("admin.php?page=wcp_folders_settings"));
311 exit;
312 }
313 }
314 }
315 }
316
317
318 function check_media_status_for_folders($status) {
319 if(defined("DOKAN_INC_DIR") && !is_admin()) {
320 return false;
321 }
322 return $status;
323 }
324
325
326 function admin_head() {
327 ?>
328 <style>
329 #adminmenu .toplevel_page_wcp_folders_settings > ul > li:last-child {
330 padding: 5px 10px;
331 }
332 #adminmenu .toplevel_page_wcp_folders_settings > ul > li:last-child a {
333 display: flex;
334 background-color: #B78DEB;
335 border-radius: 6px;
336 font-size: 12px;
337 gap: 4px;
338 padding: 4px 8px;
339 color: #ffffff;
340 align-items: center;
341 transition: all 0.2s linear;
342 font-weight: normal;
343 box-shadow: 0px 6px 8px 0px #B78DEB3D;
344 justify-content: center;
345 }
346 #adminmenu .toplevel_page_wcp_folders_settings > ul > li:last-child a:hover, #adminmenu .toplevel_page_wcp_folders_settings > ul > li:last-child a.current {
347 box-shadow: 0px 6px 8px 0px #B78DEB3D;
348 color: #ffffff;
349 background-color: #9565d0;
350 font-weight: normal;
351 }
352 #adminmenu .toplevel_page_wcp_folders_settings > ul > li:last-child a span {
353 flex: 0 0 16px;
354 height: 16px;
355 background-color: #c5a4ef;
356 border-radius: 4px;
357 padding: 2px;
358 display: inline-flex;
359 transition: all 0.2s linear;
360 }
361 #adminmenu .toplevel_page_wcp_folders_settings > ul > li:last-child a:hover span {
362 background-color: #B78DEB;
363 }
364 #adminmenu .toplevel_page_wcp_folders_settings > ul > li:last-child a span svg {
365 width: 100%;
366 height: 100%;
367 }
368 </style>
369 <?php
370 }
371
372 /**
373 * Add folders script to mailpoet's conflict list
374 *
375 * @since 2.8.7
376 * @access public
377 * @return $scripts
378 */
379 public function mailpoet_conflict_whitelist_script($scripts) {
380 $scripts[] = "folders";
381 $scripts[] = "folders-pro";
382 return $scripts;
383 }
384
385
386 /**
387 * Add folders styles to mailpoet's conflict list
388 *
389 * @since 2.8.7
390 * @access public
391 * @return $styles
392 */
393 public function mailpoet_conflict_whitelist_style($styles) {
394 $styles[] = "folders";
395 $styles[] = "folders-pro";
396 return $styles;
397 }
398
399 /**
400 * Update User Profile fields
401 *
402 * @since 2.8.5
403 * @access public
404 */
405 function save_extra_user_profile_fields( $user_id ) {
406 if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'update-user_' . $user_id ) ) {
407 return;
408 }
409
410 if (!current_user_can( 'edit_user', $user_id ) ) {
411 return;
412 }
413
414 if(isset($_POST['folders_access_role'])) {
415 $setting = get_user_meta($user_id, "folders_access_role", true);
416 if($setting === false) {
417 add_user_meta($user_id, "folders_access_role", sanitize_text_field($_POST['folders_access_role']));
418 } else {
419 update_user_meta($user_id, "folders_access_role", sanitize_text_field($_POST['folders_access_role']));
420 }
421 }
422 }
423
424 /**
425 * Fetch User Profile fields
426 *
427 * @since 2.8.5
428 * @access public
429 */
430 function extra_user_profile_fields($user) {
431 $userRoles = $this->get_user_roles();
432 $userRole = get_user_meta($user->ID, "folders_access_role", true);
433 if($userRole === false || empty($userRole)) {
434 $userRole = "default";
435 }
436 ?>
437 <h3><?php esc_html_e("Folders", "folders"); ?></h3>
438
439 <table class="form-table">
440 <tr>
441 <th><label for="folders_access_role"><?php esc_html_e("Folder Access", 'folders'); ?></label></th>
442 <td>
443 <select class="regular-text" id="folders_access_role" name="folders_access_role">
444 <?php foreach($userRoles as $key=>$role) { ?>
445 <option <?php selected($userRole, $key) ?> value="<?php echo esc_attr($key) ?>"><?php echo esc_attr($role) ?></option>
446 <?php } ?>
447 </select>
448 </td>
449 </tr>
450 </table>
451 <?php }
452
453 /**
454 * Add extra params in search
455 *
456 * @since 1.0.0
457 * @access public
458 * @return $response
459 */
460 function manage_posts_extra_fields($which) {
461 global $typenow;
462 if($which == "top" && !empty($typenow)) {
463 if ($this->folders_settings === false) {
464 $this->folders_settings = get_option('folders_settings');
465 $this->folders_settings = $this->folders_settings;
466 $this->folders_settings = is_array($this->folders_settings) ? $this->folders_settings : [];
467 }
468 if(in_array($typenow, $this->folders_settings)) {
469 $folder_type = self::get_custom_post_type($typenow);
470 if(isset($_REQUEST[$folder_type]) && !empty($_REQUEST[$folder_type])) {
471 $folder = sanitize_text_field($_REQUEST[$folder_type]);
472 echo "<input type='hidden' name='".esc_attr($folder_type)."' value='".esc_attr($folder)."' />";
473 } else if(isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == "premio_dynamic_folders" && isset($_REQUEST['dynamic_folder'])) {
474 $dynamic_folder = sanitize_text_field($_REQUEST['dynamic_folder']);
475 echo "<input type='hidden' name='ajax_action' value='premio_dynamic_folders' />";
476 echo "<input type='hidden' name='dynamic_folder' value='".esc_attr($dynamic_folder)."' />";
477 }
478 }
479 }
480 }
481
482 /**
483 * Hide CTA button text
484 *
485 * @since 1.0.0
486 * @access public
487 * @return $response
488 */
489 public function hide_folder_color_pop_up()
490 {
491 $response = [];
492 $response['status'] = 0;
493 $response['error'] = 0;
494 $response['data'] = [];
495 $response['message'] = "";
496 $postData = filter_input_array(INPUT_POST);
497 $errorCounter = 0;
498 if (!isset($postData['nonce']) || empty($postData['nonce'])) {
499 $response['message'] = esc_html__("Your request is not valid", 'folders');
500 $errorCounter++;
501 } else {
502 $nonce = self::sanitize_options($postData['nonce']);
503 if (!wp_verify_nonce($nonce, 'hide_folder_color_pop_up')) {
504 $response['message'] = esc_html__("Your request is not valid", 'folders');
505 $errorCounter++;
506 }
507 }
508
509 if ($errorCounter == 0) {
510 $response['status'] = 1;
511 add_option("hide_folder_color_pop_up", "yes");
512 }
513
514 echo wp_json_encode($response);
515 die;
516
517 }//end hide_folder_color_pop_up()
518
519 /**
520 * Hide CTA button text
521 *
522 * @since 1.0.0
523 * @access public
524 * @return $response
525 */
526 public function hide_folders_cta()
527 {
528 $response = [];
529 $response['status'] = 0;
530 $response['error'] = 0;
531 $response['data'] = [];
532 $response['message'] = "";
533 $postData = filter_input_array(INPUT_POST);
534 $errorCounter = 0;
535 if (!isset($postData['nonce']) || empty($postData['nonce'])) {
536 $response['message'] = esc_html__("Your request is not valid", 'folders');
537 $errorCounter++;
538 } else {
539 $nonce = self::sanitize_options($postData['nonce']);
540 if (!wp_verify_nonce($nonce, 'hide_folders_cta')) {
541 $response['message'] = esc_html__("Your request is not valid", 'folders');
542 $errorCounter++;
543 }
544 }
545
546 if ($errorCounter == 0) {
547 $response['status'] = 1;
548 add_option("hide_folders_cta", "yes");
549 }
550
551 echo wp_json_encode($response);
552 die;
553
554 }//end hide_folders_cta()
555
556
557 /**
558 * Delete post hook, clear data on post delete
559 *
560 * @since 1.0.0
561 * @access public
562 * @return $status
563 */
564 public function wcp_delete_post($postID)
565 {
566 delete_transient("premio_folders_without_trash");
567
568 }//end wcp_delete_post()
569
570
571 /**
572 * Remove cache when page, past added
573 *
574 * @since 1.0.0
575 * @access public
576 * @return $status
577 */
578 public function save_post($post_id, $post, $update)
579 {
580 delete_transient("premio_folders_without_trash");
581
582 }//end save_post()
583
584
585 /**
586 * Set folders data for post/page ids
587 *
588 * @since 1.0.0
589 * @access public
590 * @return $post
591 */
592 public function set_object_terms_for_folders($object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids)
593 {
594 if (!empty($object_id)) {
595 $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
596 if (!empty($tt_ids) && is_array($tt_ids)) {
597 foreach ($tt_ids as $term_id) {
598 $term = get_term($term_id, $taxonomy);
599 if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
600 unset($trash_folders[$term->term_taxonomy_id]);
601 }
602 }
603 }
604
605 if (!empty($old_tt_ids) && is_array($old_tt_ids)) {
606 foreach ($old_tt_ids as $term_id) {
607 $term = get_term($term_id, $taxonomy);
608 if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
609 unset($trash_folders[$term->term_taxonomy_id]);
610 }
611 }
612 }
613
614 if ($initial_trash_folders != $trash_folders) {
615 delete_transient("premio_folders_without_trash");
616 set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
617 }
618 }//end if
619
620 }//end set_object_terms_for_folders()
621
622
623 /**
624 * Check for folders settings
625 *
626 * @since 1.0.0
627 * @access public
628 * @return $options
629 */
630 public static function check_for_setting($key, $setting, $default="")
631 {
632 if (self::$folderSettings === false) {
633 $options = get_option("premio_folder_options");
634 if ($options === false || !is_array($options)) {
635 $options = [];
636 }
637
638 self::$folderSettings = $options;
639 }
640
641 if ($setting == "folders_settings") {
642 if (isset(self::$folderSettings[$setting]) && is_array(self::$folderSettings[$setting])) {
643 return in_array($key, self::$folderSettings[$setting]);
644 }
645 } else {
646 if (isset(self::$folderSettings[$setting][$key])) {
647 return self::$folderSettings[$setting][$key];
648 }
649 }
650
651 return false;
652
653 }//end check_for_setting()
654
655
656 /**
657 * Send message to owner on Uninstall
658 *
659 * @since 1.0.0
660 * @access public
661 * @return $response
662 */
663 public function update_folders_uninstall_status()
664 {
665 $response = [];
666 $response['status'] = 0;
667 $response['error'] = 0;
668 $response['data'] = [];
669 $response['message'] = "";
670 $postData = filter_input_array(INPUT_POST);
671 $errorCounter = 0;
672
673 if (!isset($postData['nonce']) || empty($postData['nonce'])) {
674 $response['message'] = esc_html__("Your request is not valid", 'folders');
675 $errorCounter++;
676 } else {
677 $nonce = self::sanitize_options($postData['nonce']);
678 if (!wp_verify_nonce($nonce, 'wcp_folders_uninstall_status')) {
679 $response['message'] = esc_html__("Your request is not valid", 'folders');
680 $errorCounter++;
681 }
682 }
683
684 if ($errorCounter == 0) {
685 $status = isset($postData['status']) ? $postData['status'] : "";
686 $status = ($status == "on") ? "on" : "off";
687 $customize_folders = get_option('customize_folders');
688 $customize_folders['remove_folders_when_removed'] = $status;
689 update_option("customize_folders", $customize_folders);
690 $response['status'] = 1;
691 }
692
693 echo wp_json_encode($response);
694 die;
695
696 }//end update_folders_uninstall_status()
697
698
699 /**
700 * Remove folders data
701 *
702 * @since 1.0.0
703 * @access public
704 * @return $response
705 */
706 public function remove_all_folders_data()
707 {
708 $response = [];
709 $response['status'] = 0;
710 $response['error'] = 0;
711 $response['data'] = [];
712 $response['message'] = "";
713 $postData = filter_input_array(INPUT_POST);
714 $errorCounter = 0;
715
716 if (!isset($postData['nonce']) || empty($postData['nonce'])) {
717 $response['message'] = esc_html__("Your request is not valid", 'folders');
718 $errorCounter++;
719 } else {
720 $type = self::sanitize_options($postData['type']);
721 $nonce = self::sanitize_options($postData['nonce']);
722 if (!wp_verify_nonce($nonce, 'remove_folders_data')) {
723 $response['message'] = esc_html__("Your request is not valid", 'folders');
724 $errorCounter++;
725 }
726 }
727
728 if ($errorCounter == 0) {
729 self::$folders = 0;
730 self::remove_folder_by_taxonomy("media_folder");
731 self::remove_folder_by_taxonomy("folder");
732 self::remove_folder_by_taxonomy("post_folder");
733 $post_types = get_post_types([], 'objects');
734 $post_array = [
735 "page",
736 "post",
737 "attachment",
738 ];
739 foreach ($post_types as $post_type) {
740 if (!in_array($post_type->name, $post_array)) {
741 self::remove_folder_by_taxonomy($post_type->name.'_folder');
742 }
743 }
744
745 delete_option('default_folders');
746 $response['status'] = 1;
747 $response['data'] = [
748 'items' => self::$folders,
749 ];
750 }//end if
751
752 echo wp_json_encode($response);
753 die;
754
755 }//end remove_all_folders_data()
756
757
758 /**
759 * Remove folders from poge/post
760 *
761 * @since 1.0.0
762 * @access public
763 * @return $folders
764 */
765 public static function remove_folder_by_taxonomy($taxonomy)
766 {
767 global $wpdb;
768 $query = "SELECT * FROM ".$wpdb->term_taxonomy."
769 LEFT JOIN ".$wpdb->terms."
770 ON ".$wpdb->term_taxonomy.".term_id = ".$wpdb->terms.".term_id
771 WHERE ".$wpdb->term_taxonomy.".taxonomy = '%d'
772 ORDER BY parent ASC";
773 $query = $wpdb->prepare($query, $taxonomy);
774 $folders = $wpdb->get_results($query);
775 $folders = array_values($folders);
776 foreach ($folders as $folder) {
777 $term_id = intval($folder->term_id);
778 if ($term_id) {
779 $wpdb->delete($wpdb->prefix.'term_relationships', ['term_taxonomy_id' => $term_id]);
780 $wpdb->delete($wpdb->prefix.'term_taxonomy', ['term_id' => $term_id]);
781 $wpdb->delete($wpdb->prefix.'terms', ['term_id' => $term_id]);
782 $wpdb->delete($wpdb->prefix.'termmeta', ['term_id' => $term_id]);
783 self::$folders++;
784 }
785 }
786
787 }//end remove_folder_by_taxonomy()
788
789
790 /**
791 * Convent Hex color code to RGB code
792 *
793 * @since 1.0.0
794 * @access public
795 * @return $rgb
796 */
797 public static function hexToRgb($hex, $alpha=false)
798 {
799 $hex = str_replace('#', '', $hex);
800 $length = strlen($hex);
801 $rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
802 $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
803 $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
804 if ($alpha) {
805 $rgb['a'] = $alpha;
806 }
807
808 return $rgb;
809
810 }//end hexToRgb()
811
812
813 /**
814 * Get folders by folder order
815 *
816 * @since 1.0.0
817 * @access public
818 * @return $folders
819 */
820 public function wcp_folders_by_order()
821 {
822 $response = [];
823 $response['status'] = 0;
824 $response['error'] = 0;
825 $response['data'] = [];
826 $response['message'] = "";
827 $postData = filter_input_array(INPUT_POST);
828 $errorCounter = 0;
829
830 if (!isset($postData['order']) || empty($postData['order'])) {
831 $response['message'] = esc_html__("Your request is not valid", 'folders');
832 $errorCounter++;
833 } else if (!isset($postData['type']) || empty($postData['type'])) {
834 $response['message'] = esc_html__("Your request is not valid", 'folders');
835 $errorCounter++;
836 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
837 $response['message'] = esc_html__("Your request is not valid", 'folders');
838 $errorCounter++;
839 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
840 $response['message'] = esc_html__("You have not permission to update width", 'folders');
841 $errorCounter++;
842 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
843 $response['message'] = esc_html__("You have not permission to update width", 'folders');
844 $errorCounter++;
845 } else {
846 $type = self::sanitize_options($postData['type']);
847 $nonce = self::sanitize_options($postData['nonce']);
848 if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
849 $response['message'] = esc_html__("Your request is not valid", 'folders');
850 $errorCounter++;
851 }
852 }//end if
853
854 if ($errorCounter == 0) {
855 $response['status'] = 1;
856
857 $order_field = $postData['order'];
858
859 $order_by = "";
860 $order = "ASC";
861
862 if ($order_field == "a-z" || $order_field == "z-a") {
863 $order_by = 'title';
864 if ($order_field == "z-a") {
865 $order = "DESC";
866 }
867 } else if ($order_field == "n-o" || $order_field == "o-n") {
868 $order_by = 'ID';
869 if ($order_field == "o-n") {
870 $order = "ASC";
871 } else {
872 $order = "DESC";
873 }
874 }
875
876 if (empty($order_by)) {
877 $order = "";
878 }
879
880 $post_type = esc_attr($postData['type']);
881 $customizeFolders = get_option('customize_folders', []);
882 if(isset($customizeFolders['force_sorting']) && $customizeFolders['force_sorting'] == "on"){
883 update_option("wcp_custom_sort_".$post_type, $order_field);
884 }
885
886 $folder_type = self::get_custom_post_type($postData['type']);
887 // Do not change: Free/Pro Class name change
888 $tree_data = WCP_Tree::get_full_tree_data($folder_type, $order_by, $order);
889
890 $response['data'] = $tree_data['string'];
891 $taxonomies = [];
892 if ($postData['type'] == "attachment") {
893 $taxonomies = self::get_terms_hierarchical($folder_type);
894 }
895
896 $response['terms'] = $taxonomies;
897 }//end if
898
899 echo wp_json_encode($response);
900 die;
901
902 }//end wcp_folders_by_order()
903
904
905 /**
906 * Save selected post for page/post/media
907 *
908 * @since 1.0.0
909 * @access public
910 * @return $folders
911 */
912 public function save_folder_last_status()
913 {
914 $postData = filter_input_array(INPUT_POST);
915 $error = 0;
916 if (!isset($postData['post_id']) || empty($postData['post_id'])) {
917 $response['message'] = esc_html__("Your request is not valid", 'folders');
918 $error = 1;
919 } else if (!isset($postData['post_type']) || empty($postData['post_type'])) {
920 $response['message'] = esc_html__("Your request is not valid", 'folders');
921 $error = 1;
922 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
923 $response['message'] = esc_html__("Your request is not valid", 'folders');
924 $error = 1;
925 } else if ($postData['post_type'] == "page" && !current_user_can("edit_pages")) {
926 $response['message'] = esc_html__("You have not permission to update width", 'folders');
927 $error = 1;
928 } else if ($postData['post_type'] != "page" && !current_user_can("edit_posts")) {
929 $response['message'] = esc_html__("You have not permission to update width", 'folders');
930 $error = 1;
931 }
932
933 if ($error == 0) {
934 $post_type = filter_input(INPUT_POST, 'post_type');
935 $post_id = filter_input(INPUT_POST, 'post_id');
936 if (!empty($post_type) && !empty($post_id)) {
937 delete_option("last_folder_status_for".$post_type);
938 add_option("last_folder_status_for".$post_type, $post_id);
939 }
940 }
941
942 }//end save_folder_last_status()
943
944
945 /**
946 * Save selected post for page/post/media
947 *
948 * @since 1.0.0
949 * @access public
950 * @return $folders
951 */
952 public function media_modal_query_final_terms($request)
953 {
954 $action = $this->getRequestVar("action");
955 if ($action == "mla-query-attachments") {
956 $query = $this->getRequestVar("query");
957 if (isset($query['media_folder']) && !empty($query['media_folder'])) {
958 if ($query['media_folder'] == -1) {
959 $tax_query = [
960 'taxonomy' => 'media_folder',
961 'operator' => 'NOT EXISTS',
962 ];
963 $request['tax_query'] = [$tax_query];
964 $request = apply_filters('media_library_organizer_media_filter_attachments', $request, $_REQUEST);
965 } else {
966 $request['media_folder'] = $query['media_folder'];
967 }
968 }
969 }
970
971 return $request;
972
973 }//end media_modal_query_final_terms()
974
975
976 /**
977 * Filter folders without trash count
978 *
979 * @since 1.0.0
980 * @access public
981 */
982 public function get_terms_filter_without_trash($terms, $taxonomies, $args) {
983 $isForFolders = 0;
984 if(!empty($taxonomies) && is_array($taxonomies) && count($taxonomies)){
985 foreach ($taxonomies as $taxonomy) {
986 if (in_array($taxonomy, array("media_folder", "folder", "post_folder"))) {
987 $isForFolders = 1;
988 } else {
989 $folder = substr($taxonomy, -7);
990 if ($folder == "_folder") {
991 $isForFolders = 1;
992 }
993 }
994 }
995 }
996
997 if($isForFolders) {
998 global $wpdb;
999 if (!is_array($terms) && count($terms) < 1) {
1000 return $terms;
1001 }
1002
1003 $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
1004
1005 if ($trash_folders === false) {
1006 $trash_folders = array();
1007 $initial_trash_folders = array();
1008 }
1009
1010 $post_table = $wpdb->prefix . "posts";
1011 $term_table = $wpdb->prefix . "term_relationships";
1012 $options = get_option('folders_settings');
1013 $option_array = array();
1014 if (!empty($options)) {
1015 foreach ($options as $option) {
1016 $option_array[] = self::get_custom_post_type($option);
1017 }
1018 }
1019 foreach ($terms as $key => $term) {
1020 if (isset($term->term_id) && isset($term->taxonomy) && !empty($term->taxonomy) && in_array($term->taxonomy, $option_array)) {
1021 $trash_count = null;
1022 if (has_filter("premio_folder_item_in_taxonomy")) {
1023 $post_type = "";
1024 $taxonomy = $term->taxonomy;
1025
1026 if ($taxonomy == "post_folder") {
1027 $post_type = "post";
1028 } else if ($taxonomy == "folder") {
1029 $post_type = "page";
1030 } else if ($taxonomy == "media_folder") {
1031 $post_type = "attachment";
1032 } else {
1033 $post_type = trim($taxonomy, "'_folder'");
1034 }
1035 $arg = array(
1036 'post_type' => $post_type,
1037 'taxonomy' => $taxonomy,
1038 );
1039 $trash_count = apply_filters("premio_folder_item_in_taxonomy", $term->term_id, $arg);
1040 } else {
1041 if ($trash_count == null && isset($trash_folders[$term->term_taxonomy_id])) {
1042 $trash_count = $trash_folders[$term->term_taxonomy_id];
1043 } else if ($trash_count == null) {
1044
1045 if ($trash_count === null) {
1046 $query = "SELECT COUNT(DISTINCT(p.ID))
1047 FROM {$post_table} p
1048 JOIN {$term_table} rl ON p.ID = rl.object_id
1049 WHERE rl.term_taxonomy_id = '{$term->term_taxonomy_id}'
1050 AND p.post_status != 'trash'
1051 AND p.post_status != 'auto-draft'
1052 LIMIT 1";
1053 $result = $wpdb->get_var($query);
1054 if (intval($result) > 0) {
1055 $trash_count = intval($result);
1056 } else {
1057 $trash_count = 0;
1058 }
1059 }
1060 }
1061 }
1062 if ($trash_count === null) {
1063 $trash_count = 0;
1064 }
1065 $terms[$key]->trash_count = $trash_count;
1066 $trash_folders[$term->term_taxonomy_id] = $trash_count;
1067 }
1068 }
1069
1070 if (!empty($terms) && $initial_trash_folders != $trash_folders) {
1071 delete_transient("premio_folders_without_trash");
1072 set_transient("premio_folders_without_trash", $trash_folders, 3 * DAY_IN_SECONDS);
1073 }
1074 }
1075 return $terms;
1076 }//end get_terms_filter_without_trash()
1077
1078
1079 /**
1080 * Add Checkbox to page/post lists
1081 *
1082 * @since 1.0.0
1083 * @access public
1084 * @return $folders
1085 */
1086 public function custom_bulk_action($bulk_actions)
1087 {
1088 $bulk_actions['move_to_folder'] = esc_html__('Move to Folder', 'folders');
1089 return $bulk_actions;
1090
1091 }//end custom_bulk_action()
1092
1093
1094 /**
1095 * Folders domain for language translation
1096 *
1097 * @since 1.0.0
1098 * @access public
1099 * @return $folders
1100 */
1101 public function folders_text()
1102 {
1103 load_plugin_textdomain("folders", false, dirname(dirname(plugin_basename(__FILE__))).'/languages/');
1104
1105 }//end folders_text()
1106
1107
1108 /**
1109 * Add custom CSS to footer for media button
1110 *
1111 * @since 1.0.0
1112 * @access public
1113 * @return $folders
1114 */
1115 public function admin_footer_for_media()
1116 {
1117 $customize_folders = get_option('customize_folders');
1118 if (isset($customize_folders['dropdown_color']) && !empty($customize_folders['dropdown_color'])) {
1119 ?>
1120 <style>
1121 #media-attachment-taxonomy-filter, .post-upload-ui .folder_for_media, select.media-select-folder {
1122 border-color: <?php echo esc_attr($customize_folders['dropdown_color']) ?>;
1123 color: <?php echo esc_attr($customize_folders['dropdown_color']) ?>
1124 }
1125 .folder_for_media option {
1126 color:#000000;
1127 }
1128 .folder_for_media option:first-child {
1129 font-weight: bold;
1130 }
1131 </style>
1132 <?php
1133 }
1134
1135 }//end admin_footer_for_media()
1136
1137
1138 /**
1139 * Check for default page/post/media folder on load
1140 *
1141 * @since 1.0.0
1142 * @access public
1143 * @return $folders
1144 */
1145 public function check_for_default_folders()
1146 {
1147 global $typenow, $current_screen;
1148 $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0;
1149 $options = get_option('folders_settings');
1150 $options = (empty($options) || !is_array($options)) ? [] : $options;
1151 $post_status = filter_input(INPUT_GET, 'post_status');
1152 $last_status = get_option("last_folder_status_for".$typenow);
1153 if (empty($post_status) && !$isAjax && (in_array($typenow, $options) || !empty($last_status)) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) {
1154 $requests = filter_input_array(INPUT_GET);
1155 $requests = empty($requests)||!is_array($requests) ? [] : $requests;
1156
1157 if ($typenow == "attachment") {
1158 if (count($requests) > 0) {
1159 return;
1160 }
1161 } else if ($typenow == "post") {
1162 if (count($requests) > 0) {
1163 return;
1164 }
1165 } else {
1166 if (count($requests) > 1) {
1167 return;
1168 }
1169 }
1170
1171 if (!empty($last_status)) {
1172 $status = 1;
1173 if ($last_status != "-1" && $last_status != "all") {
1174 $type = self::get_custom_post_type($typenow);
1175 $term = get_term_by('slug', $last_status, $type);
1176 if (empty($term) || !is_object($term)) {
1177 $status = 0;
1178 }
1179 }
1180
1181 delete_option("last_folder_status_for".$typenow);
1182 if ($last_status == "all") {
1183 $last_status = "";
1184 }
1185
1186 if ($status) {
1187 if ($typenow == "attachment") {
1188 if (!isset($_REQUEST['media_folder'])) {
1189 ?>
1190 <script>
1191 window.location = '<?php echo esc_url(admin_url())."upload.php?post_type=attachment&media_folder=".esc_attr($last_status) ?>';
1192 </script>
1193 <?php
1194 exit;
1195 }
1196 } else {
1197 $post_type = self::get_custom_post_type($typenow);
1198 if (!isset($_REQUEST[$post_type])) {
1199 ?>
1200 <script>
1201 window.location = '<?php echo esc_url(admin_url())."edit.php?post_type=".esc_attr($typenow)."&".esc_attr($post_type)."=".esc_attr($last_status) ?>';
1202 </script>
1203 <?php
1204 exit;
1205 }
1206 }//end if
1207 }//end if
1208 }//end if
1209
1210 $default_folders = get_option('default_folders');
1211 $default_folders = (empty($default_folders) || !is_array($default_folders)) ? [] : $default_folders;
1212
1213 $status = 1;
1214 if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
1215 $type = self::get_custom_post_type($typenow);
1216 if ($default_folders[$typenow] != -1) {
1217 $term = get_term_by('slug', $default_folders[$typenow], $type);
1218 if (empty($term) || !is_object($term)) {
1219 $status = 0;
1220 }
1221 }
1222 } else {
1223 $status = 0;
1224 }
1225
1226 if ($status) {
1227 if ($typenow == "attachment") {
1228 if (!isset($_REQUEST['media_folder'])) {
1229 if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
1230 ?>
1231 <script>
1232 window.location = '<?php echo esc_url(admin_url())."upload.php?post_type=attachment&media_folder=".esc_attr($default_folders[$typenow]) ?>';
1233 </script>
1234 <?php
1235 exit;
1236 }
1237 }
1238 } else {
1239 $search = filter_input(INPUT_GET, "s");
1240 if (!empty($search)) {
1241 $search = esc_attr($search);
1242 } else {
1243 $search = "";
1244 }
1245
1246 $post_type = self::get_custom_post_type($typenow);
1247 if (!isset($_REQUEST[$post_type])) {
1248 if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
1249 ?>
1250 <script>
1251 window.location = '<?php echo esc_url(admin_url())."edit.php?post_type=".esc_attr($typenow)."&".esc_attr($post_type)."=".esc_attr($default_folders[$typenow])."&s=".esc_attr($search) ?>';
1252 </script>
1253 <?php
1254 exit;
1255 }
1256 }
1257 }//end if
1258 }//end if
1259 }//end if
1260
1261 }//end check_for_default_folders()
1262
1263
1264 /**
1265 * Signup for folders news
1266 *
1267 * @since 1.0.0
1268 * @access public
1269 * @return $folders
1270 */
1271 public function folder_update_status()
1272 {
1273 $response = [];
1274 $response['status'] = 0;
1275 $nonce = filter_input(INPUT_POST, 'nonce');
1276 if (!empty($nonce) && wp_verify_nonce($nonce, 'folder_update_status')) {
1277 $status = filter_input(INPUT_POST, 'status');
1278 $email = filter_input(INPUT_POST, 'email');
1279 update_option("folder_update_message", 2);
1280 if ($status == 1) {
1281 $url = 'https://premioapps.com/premio/signup/email.php';
1282 $apiParams = [
1283 'plugin' => 'folders',
1284 'email' => $email,
1285 ];
1286
1287 // Signup Email for Folders
1288 $apiResponse = wp_safe_remote_post($url, ['body' => $apiParams, 'timeout' => 15, 'sslverify' => true]);
1289
1290 if (is_wp_error($apiResponse)) {
1291 wp_safe_remote_post($url, ['body' => $apiParams, 'timeout' => 15, 'sslverify' => false]);
1292 }
1293
1294 $response['status'] = 1;
1295 }
1296 }//end if
1297
1298 echo wp_json_encode($response);
1299 die;
1300
1301 }//end folder_update_status()
1302
1303
1304 /**
1305 * Add category to media
1306 *
1307 * @since 1.0.0
1308 * @access public
1309 * @return $folders
1310 */
1311 public function add_attachment_category($post_ID)
1312 {
1313 if (self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
1314 $folder_id = null;
1315 if (isset($_REQUEST["folder_for_media"])) {
1316 $folder_id = $this->getRequestVar("folder_for_media");
1317 }
1318
1319 if ($folder_id !== null) {
1320 $folder_id = (int) $folder_id;
1321 $folder_id = self::sanitize_options($folder_id, "int");
1322 if ($folder_id > 0) {
1323 $post_type = self::get_custom_post_type("attachment");
1324 $term = get_term($folder_id);
1325 if (!empty($term) && isset($term->slug)) {
1326 wp_set_object_terms($post_ID, $term->slug, $post_type);
1327
1328 $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
1329 if ($trash_folders === false) {
1330 $trash_folders = [];
1331 $initial_trash_folders = [];
1332 }
1333
1334 if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
1335 unset($trash_folders[$term->term_taxonomy_id]);
1336 }
1337
1338 if ($initial_trash_folders != $trash_folders) {
1339 delete_transient("premio_folders_without_trash");
1340 set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
1341 }
1342 }
1343 }//end if
1344 }//end if
1345 }//end if
1346
1347 }//end add_attachment_category()
1348
1349
1350 /**
1351 * Get Dropdown data for media popup
1352 *
1353 * @since 1.0.0
1354 * @access public
1355 * @return $folders
1356 */
1357 public function show_dropdown_on_media_screen()
1358 {
1359 if (self::is_for_this_post_type('attachment')) {
1360 $post_type = self::get_custom_post_type('attachment');
1361 global $typenow, $current_screen;
1362 // Free/Pro Class name change
1363 if (!class_exists('WCP_Tree')) {
1364 $files = [
1365 'WCP_Tree' => WCP_DS."includes".WCP_DS."tree.class.php",
1366 ];
1367
1368 foreach ($files as $file) {
1369 if (file_exists(dirname(dirname(__FILE__)).$file)) {
1370 include_once dirname(dirname(__FILE__)).$file;
1371 }
1372 }
1373 }
1374
1375 // Free/Pro Class name change
1376 $options = WCP_Tree::get_folder_option_data($post_type);?>
1377 <p class="attachments-category"><?php esc_html_e("Select a folder (Optional)", 'folders'); ?></p>
1378 <p class="attachments-category"><?php esc_html_e("First select the folder, and then upload the files", 'folders'); ?><br/></p>
1379 <p>
1380 <?php
1381 $request = sanitize_text_field($_SERVER['REQUEST_URI']);
1382 $request = strpos($request, "post.php");
1383 ?>
1384 <select name="folder_for_media" class="folder_for_media">
1385 <option value="-1">- <?php esc_html_e('Unassigned', 'folders'); ?></option>
1386 <?php echo ($options) ?>
1387 <?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')) {?>
1388 <option value="add-folder"><?php esc_html_e('+ Create a New Folder', 'folders'); ?></option>
1389 <?php } ?>
1390 </select>
1391 </p>
1392 <?php
1393 }//end if
1394
1395 }//end show_dropdown_on_media_screen()
1396
1397
1398 /**
1399 * Hide folders
1400 *
1401 * @since 1.0.0
1402 * @access public
1403 * @return $folders
1404 */
1405 public function wcp_hide_folders()
1406 {
1407 $response = [];
1408 $response['status'] = 0;
1409 $response['error'] = 0;
1410 $response['data'] = [];
1411 $response['message'] = "";
1412 $postData = filter_input_array(INPUT_POST);
1413 $errorCounter = 0;
1414
1415 if (!isset($postData['status']) || empty($postData['status'])) {
1416 $response['message'] = esc_html__("Your request is not valid", 'folders');
1417 $errorCounter++;
1418 } else if (!isset($postData['type']) || empty($postData['type'])) {
1419 $response['message'] = esc_html__("Your request is not valid", 'folders');
1420 $errorCounter++;
1421 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1422 $response['message'] = esc_html__("Your request is not valid", 'folders');
1423 $errorCounter++;
1424 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
1425 $response['message'] = esc_html__("You have not permission to update width", 'folders');
1426 $errorCounter++;
1427 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
1428 $response['message'] = esc_html__("You have not permission to update width", 'folders');
1429 $errorCounter++;
1430 } else {
1431 $type = self::sanitize_options($postData['type']);
1432 $nonce = self::sanitize_options($postData['nonce']);
1433 if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
1434 $response['message'] = esc_html__("Your request is not valid", 'folders');
1435 $errorCounter++;
1436 }
1437 }//end if
1438
1439 if ($errorCounter == 0) {
1440 $type = self::sanitize_options($postData['type']);
1441 $status = self::sanitize_options($postData['status']);
1442 $optionName = "wcp_folder_display_status_".$type;
1443 update_option($optionName, $status);
1444 $response['status'] = 1;
1445 }
1446
1447 echo wp_json_encode($response);
1448 wp_die();
1449
1450 }//end wcp_hide_folders()
1451
1452
1453 /**
1454 * Change status for folders
1455 *
1456 * @since 1.0.0
1457 * @access public
1458 * @return $folders
1459 */
1460 public function wcp_change_folder_display_status()
1461 {
1462 $response = [];
1463 $response['status'] = 0;
1464 $response['error'] = 0;
1465 $response['data'] = [];
1466 $response['message'] = "";
1467 $postData = filter_input_array(INPUT_POST);
1468 $errorCounter = 0;
1469 if (!isset($postData['status']) || empty($postData['status'])) {
1470 $response['message'] = esc_html__("Your request is not valid", 'folders');
1471 $errorCounter++;
1472 } else if (!isset($postData['type']) || empty($postData['type'])) {
1473 $response['message'] = esc_html__("Your request is not valid", 'folders');
1474 $errorCounter++;
1475 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1476 $response['message'] = esc_html__("Your request is not valid", 'folders');
1477 $errorCounter++;
1478 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
1479 $response['message'] = esc_html__("You have not permission to update width", 'folders');
1480 $errorCounter++;
1481 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
1482 $response['message'] = esc_html__("You have not permission to update width", 'folders');
1483 $errorCounter++;
1484 } else {
1485 $type = self::sanitize_options($postData['type']);
1486 $nonce = self::sanitize_options($postData['nonce']);
1487 if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
1488 $response['message'] = esc_html__("Your request is not valid", 'folders');
1489 $errorCounter++;
1490 }
1491 }//end if
1492
1493 if ($errorCounter == 0) {
1494 $type = self::sanitize_options($postData['type']);
1495 $width = self::sanitize_options($postData['status']);
1496 $optionName = "wcp_dynamic_display_status_".$type;
1497 update_option($optionName, $width);
1498 $response['status'] = 1;
1499 }
1500
1501 echo wp_json_encode($response);
1502 wp_die();
1503
1504 }//end wcp_change_folder_display_status()
1505
1506
1507 /**
1508 * Check for folders for page/post/media id
1509 *
1510 * @since 1.0.0
1511 * @access public
1512 * @return $folders
1513 */
1514 public function premio_check_for_other_folders()
1515 {
1516 $response = [];
1517 $response['status'] = 0;
1518 $response['error'] = 0;
1519 $response['data'] = [];
1520 $response['message'] = "";
1521 $postData = filter_input_array(INPUT_POST);
1522 $errorCounter = 0;
1523 if (!isset($postData['post_id']) || empty($postData['post_id'])) {
1524 $response['message'] = esc_html__("Your request is not valid", 'folders');
1525 $errorCounter++;
1526 } else if (!isset($postData['type']) || empty($postData['type'])) {
1527 $response['message'] = esc_html__("Your request is not valid", 'folders');
1528 $errorCounter++;
1529 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1530 $response['message'] = esc_html__("Your request is not valid", 'folders');
1531 $errorCounter++;
1532 } else if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['type'])) {
1533 $response['message'] = esc_html__("Your request is not valid", 'folders');
1534 $errorCounter++;
1535 } else if (!current_user_can("manage_categories")) {
1536 $response['message'] = esc_html__("Your request is not valid", 'folders');
1537 $errorCounter++;
1538 }
1539
1540 if ($errorCounter == 0) {
1541 $folderUndoSettings = [];
1542 $type = self::sanitize_options($postData['type']);
1543 $post_id = self::sanitize_options($postData['post_id']);
1544
1545 $post_id = explode(",", $post_id);
1546
1547 $taxonomy = self::get_custom_post_type($type);
1548
1549 foreach ($post_id as $id) {
1550 $terms = get_the_terms($id, $taxonomy);
1551 if (!empty($terms) && is_array($terms)) {
1552 foreach ($terms as $term) {
1553 if ($term->term_id != $postData['taxonomy']) {
1554 $response['status'] = -1;
1555 $response['data']['post_id'] = $postData['post_id'];
1556 echo wp_json_encode($response);
1557 wp_die();
1558 }
1559 }
1560 }
1561 }
1562
1563 $this->wcp_remove_post_folder();
1564 }//end if
1565
1566 echo wp_json_encode($response);
1567 wp_die();
1568
1569 }//end premio_check_for_other_folders()
1570
1571 public function wcp_change_color_folder()
1572 {
1573 $response = [];
1574 $response['status'] = 0;
1575 $response['error'] = 0;
1576 $response['data'] = [];
1577 $response['message'] = "";
1578 $response['id'] = [];
1579
1580 $postData = filter_input_array(INPUT_POST);
1581 $errorCounter = 0;
1582 if (!current_user_can("manage_categories")) {
1583 $response['message'] = esc_html__("You have not permission to update folder", 'folders');
1584 $errorCounter++;
1585 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1586 $errorCounter++;
1587 $response['message'] = esc_html__("Your request is not valid", 'folders');
1588 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1589 $response['message'] = esc_html__("Your request is not valid", 'folders');
1590 $errorCounter++;
1591 } else {
1592 $term_id = self::sanitize_options($postData['term_id']);
1593 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
1594 $response['message'] = esc_html__("Your request is not valid", 'folders');
1595 $errorCounter++;
1596 }
1597 }
1598
1599 if ($errorCounter == 0) {
1600 $term_id = self::sanitize_options($postData['term_id']);
1601 $getColor = self::sanitize_options($postData['color']);
1602
1603 $folder_info = get_term_meta($term_id, "folder_info", true);
1604
1605 if ($folder_info) {
1606 $folder_info['has_color'] = $getColor;
1607 update_term_meta($term_id, "folder_info", $folder_info);
1608 } else {
1609 $folder_info = [];
1610 $folder_info['has_color'] = $getColor;
1611 add_term_meta($term_id, "folder_info", $folder_info);
1612 }
1613 $response['id'] = $term_id;
1614 $response['status'] = 1;
1615 }
1616
1617 echo wp_json_encode($response);
1618 wp_die();
1619
1620 }//end wcp_change_color_folder()
1621
1622 /**
1623 * Remove Folder
1624 *
1625 * @since 1.0.0
1626 * @access public
1627 * @return $folders
1628 */
1629 public function wcp_remove_post_folder()
1630 {
1631 $response = [];
1632 $response['status'] = 0;
1633 $response['error'] = 0;
1634 $response['data'] = [];
1635 $response['message'] = "";
1636 $postData = filter_input_array(INPUT_POST);
1637 $errorCounter = 0;
1638 if (!isset($postData['post_id']) || empty($postData['post_id'])) {
1639 $response['message'] = esc_html__("Your request is not valid", 'folders');
1640 $errorCounter++;
1641 } else if (!isset($postData['type']) || empty($postData['type'])) {
1642 $response['message'] = esc_html__("Your request is not valid", 'folders');
1643 $errorCounter++;
1644 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1645 $response['message'] = esc_html__("Your request is not valid", 'folders');
1646 $errorCounter++;
1647 } else if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['type'])) {
1648 $response['message'] = esc_html__("Your request is not valid", 'folders');
1649 $errorCounter++;
1650 } else if (!current_user_can("manage_categories")) {
1651 $response['message'] = esc_html__("Your request is not valid", 'folders');
1652 $errorCounter++;
1653 }
1654
1655 if ($errorCounter == 0) {
1656 $folderUndoSettings = [];
1657 $type = self::sanitize_options($postData['type']);
1658 $post_id = self::sanitize_options($postData['post_id']);
1659
1660 $post_id = explode(",", $post_id);
1661
1662 $taxonomy = self::get_custom_post_type($type);
1663
1664 $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
1665 if ($trash_folders === false) {
1666 $trash_folders = [];
1667 $initial_trash_folders = [];
1668 }
1669
1670 foreach ($post_id as $id) {
1671 if (!empty($id) && is_numeric($id) && $id > 0) {
1672 $terms = get_the_terms($id, $taxonomy);
1673 $post_terms = [
1674 'post_id' => $id,
1675 'terms' => $terms,
1676 ];
1677 if (!empty($terms) && count($terms) > 0) {
1678 foreach ($terms as $term) {
1679 if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
1680 unset($trash_folders[$term->term_taxonomy_id]);
1681 }
1682 }
1683 }
1684
1685 $folderUndoSettings[] = $post_terms;
1686 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'])) {
1687 wp_remove_object_terms($id, intval($postData['active_folder']), $taxonomy);
1688 } else {
1689 wp_delete_object_term_relationships($id, $taxonomy);
1690 }
1691 }//end if
1692 }//end foreach
1693
1694 delete_transient("folder_undo_settings");
1695 set_transient("folder_undo_settings", $folderUndoSettings, DAY_IN_SECONDS);
1696
1697 if ($initial_trash_folders != $trash_folders) {
1698 delete_transient("premio_folders_without_trash");
1699 set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
1700 }
1701
1702 $response['status'] = 1;
1703 }//end if
1704
1705 echo wp_json_encode($response);
1706 wp_die();
1707
1708 }//end wcp_remove_post_folder()
1709
1710
1711 /**
1712 * Filter records by selected categories
1713 *
1714 * @since 1.0.0
1715 * @access public
1716 * @return $folders
1717 */
1718 public function filter_record_list($query)
1719 {
1720 global $typenow;
1721
1722 if ($typenow == "attachment") {
1723 return;
1724 }
1725
1726 if (!self::is_for_this_post_type($typenow)) {
1727 return $query;
1728 }
1729
1730 $taxonomy = self::get_custom_post_type($typenow);
1731
1732 if (! isset($query->query['post_type'])) {
1733 return $query;
1734 }
1735
1736 if (! isset($_REQUEST[$taxonomy])) {
1737 return $query;
1738 }
1739
1740 $term = sanitize_text_field($_REQUEST[$taxonomy]);
1741 if ($term != "-1") {
1742 return $query;
1743 }
1744
1745 unset($query->query_vars[$taxonomy]);
1746
1747 $tax_query = [
1748 'taxonomy' => $taxonomy,
1749 'operator' => 'NOT EXISTS',
1750 ];
1751
1752 $query->set('tax_query', [ $tax_query ]);
1753 $query->tax_query = new WP_Tax_Query([ $tax_query ]);
1754
1755 return $query;
1756
1757 }//end filter_record_list()
1758
1759
1760 /**
1761 * Get folders list
1762 *
1763 * @since 1.0.0
1764 * @access public
1765 * @return $folders
1766 */
1767 public function wcp_get_default_list()
1768 {
1769
1770 $postData = filter_input_array(INPUT_POST);
1771
1772 $post_type = $postData['type'];
1773
1774 $ttpsts = $this->get_ttlpst($post_type);
1775
1776 $empty_items = self::get_tempt_posts($post_type);
1777
1778 $post_type = self::get_custom_post_type($post_type);
1779
1780 $taxonomies = self::get_terms_hierarchical($post_type);
1781
1782 $response = [
1783 'status' => 1,
1784 'total_items' => $ttpsts,
1785 'taxonomies' => $taxonomies,
1786 'empty_items' => $empty_items,
1787 ];
1788 echo wp_json_encode($response);
1789 wp_die();
1790
1791 }//end wcp_get_default_list()
1792
1793
1794 /**
1795 * Get folders list
1796 *
1797 * @since 1.0.0
1798 * @access public
1799 * @return $folders
1800 */
1801 function get_folders_default_list()
1802 {
1803 $postData = filter_input_array(INPUT_POST);
1804
1805 $post_type = $postData['type'];
1806
1807 $ttpsts = $this->get_ttlpst($post_type);
1808
1809 $empty_items = self::get_tempt_posts($post_type);
1810
1811 $post_type = self::get_custom_post_type($post_type);
1812
1813 $taxonomies = self::get_terms_hierarchical($post_type);
1814
1815 $response = [
1816 'status' => 1,
1817 'total_items' => $ttpsts,
1818 'empty_items' => $empty_items,
1819 'taxonomies' => $taxonomies,
1820 ];
1821 echo wp_json_encode($response);
1822 die;
1823
1824 }//end get_folders_default_list()
1825
1826
1827 /**
1828 * Save folders data for page/post id
1829 *
1830 * @since 1.0.0
1831 * @access public
1832 * @return $folders
1833 */
1834 function save_media_terms($post_id)
1835 {
1836 if (wp_is_post_revision($post_id)) {
1837 return;
1838 }
1839
1840 $post = get_post($post_id);
1841 if ($post->post_type !== 'attachment') {
1842 return;
1843 }
1844
1845 $post_type = self::get_custom_post_type('attachment');
1846 $selected_folder = get_option("selected_".esc_attr($post_type)."_folder");
1847 if ($selected_folder != null && !empty($selected_folder)) {
1848 $terms = get_term($selected_folder);
1849 if (!empty($terms) && isset($terms->term_id)) {
1850 wp_set_post_terms($post_id, $terms->term_id, $post_type, false);
1851 }
1852 }
1853
1854 }//end save_media_terms()
1855
1856
1857 /**
1858 * Filter attachment data by folder
1859 *
1860 * @since 1.0.0
1861 * @access public
1862 * @return $folders
1863 */
1864 public function filter_attachments_grid($args)
1865 {
1866 $taxonomy = 'media_folder';
1867 if (! isset($args[$taxonomy])) {
1868 return $args;
1869 }
1870
1871 $term = sanitize_text_field($args[$taxonomy]);
1872 if ($term != "-1") {
1873 return $args;
1874 }
1875
1876 unset($args[$taxonomy]);
1877 $args['tax_query'] = [
1878 [
1879 'taxonomy' => $taxonomy,
1880 'operator' => 'NOT EXISTS',
1881 ],
1882 ];
1883 $args = apply_filters('media_library_organizer_media_filter_attachments_grid', $args);
1884 return $args;
1885
1886 }//end filter_attachments_grid()
1887
1888
1889 /**
1890 * Returns total folders
1891 *
1892 * @since 1.0.0
1893 * @access public
1894 */
1895 public function get_tempt_posts($post_type="")
1896 {
1897 global $wpdb;
1898
1899 $post_table = $wpdb->prefix."posts";
1900 $term_table = $wpdb->prefix."term_relationships";
1901 $term_taxonomy_table = $wpdb->prefix."term_taxonomy";
1902 $term_meta = $wpdb->prefix."termmeta";
1903 $taxonomy = self::get_custom_post_type($post_type);
1904 $tlrcds = null;
1905 if(has_filter("premio_folder_un_categorized_items")) {
1906 $tlrcds = apply_filters("premio_folder_un_categorized_items", $post_type, $taxonomy);
1907 }
1908 if($tlrcds === null) {
1909 $user_filter = false;
1910
1911 if(!$user_filter) {
1912 if ($post_type != "attachment") {
1913 $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND (
1914 NOT EXISTS (
1915 SELECT 1
1916 FROM {$term_table}
1917 INNER JOIN {$term_taxonomy_table}
1918 ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id
1919 WHERE {$term_taxonomy_table}.taxonomy = '%s'
1920 AND {$term_table}.object_id = {$post_table}.ID
1921 )
1922 ) 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' OR {$post_table}.post_status = 'pending'))";
1923 $query = $wpdb->prepare($query, $taxonomy, $post_type);
1924 } else {
1925 $select = "SELECT COUNT(DISTINCT(P.ID)) AS total_records FROM {$post_table} AS P";
1926 $where = ["post_type = 'attachment' "];
1927 $where[] = "(post_status = 'inherit' OR post_status = 'private')";
1928 $where[] = "(NOT EXISTS (
1929 SELECT 1
1930 FROM {$term_table}
1931 INNER JOIN {$term_taxonomy_table}
1932 ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id
1933 WHERE {$term_taxonomy_table}.taxonomy = '%s'
1934 AND {$term_table}.object_id = P.ID
1935 )
1936 )";
1937
1938 $join = apply_filters( 'folders_count_join_query', "" );
1939 $where = apply_filters( 'folders_count_where_query', $where );
1940
1941 $query = $select . $join . " WHERE ".implode( ' AND ', $where );
1942
1943 $query = $wpdb->prepare($query, $taxonomy);
1944 }
1945 } else {
1946 if ($post_type != "attachment") {
1947 $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND (
1948 NOT EXISTS (
1949 SELECT 1
1950 FROM {$term_table}
1951 INNER JOIN {$term_taxonomy_table}
1952 ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id
1953 INNER JOIN {$term_meta}
1954 ON {$term_meta}.term_id = {$term_table}.term_taxonomy_id
1955 WHERE {$term_taxonomy_table}.taxonomy = '%s'
1956 AND {$term_table}.object_id = {$post_table}.ID
1957 )
1958 ) 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' OR {$post_table}.post_status = 'pending'))";
1959 $query = $wpdb->prepare($query, $taxonomy, $post_type);
1960 } else {
1961 $select = "SELECT COUNT(DISTINCT(P.ID)) AS total_records FROM {$post_table} AS P";
1962 $where = ["post_type = 'attachment' "];
1963 $where[] = "(post_status = 'inherit' OR post_status = 'private')";
1964 $where[] = "(
1965 NOT EXISTS (
1966 SELECT 1
1967 FROM {$term_table}
1968 INNER JOIN {$term_taxonomy_table}
1969 ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id
1970 INNER JOIN {$term_meta}
1971 ON {$term_meta}.term_id = {$term_table}.term_taxonomy_id
1972 WHERE {$term_taxonomy_table}.taxonomy = '%s'
1973 AND {$term_table}.object_id = P.ID
1974 )
1975 )";
1976
1977 $join = apply_filters( 'folders_count_join_query', "" );
1978 $where = apply_filters( 'folders_count_where_query', $where );
1979
1980 $query = $select . $join . " WHERE ".implode( ' AND ', $where );
1981
1982 $query = $wpdb->prepare($query, $taxonomy);
1983 }
1984 }
1985
1986 $tlrcds = $wpdb->get_var($query);
1987 }
1988
1989 if(!empty($tlrcds)) {
1990 return $tlrcds;
1991 } else {
1992 return 0;
1993 }
1994
1995 }//end get_tempt_posts()
1996
1997
1998 /**
1999 * Generates the default folder link based on the taxonomy and default folders provided.
2000 *
2001 * @param string $taxonomy The taxonomy type (e.g., 'attachment', 'post', etc.).
2002 * @param array $default_folders The associative array of default folder slugs keyed by taxonomy type.
2003 * @return string The generated URL of the default folder link for the specified taxonomy.
2004 */
2005 function get_default_folder_link($taxonomy, $default_folders)
2006 {
2007 $link = '';
2008 if (isset($default_folders[$taxonomy]) && !empty($default_folders[$taxonomy])) {
2009 $type = self::get_custom_post_type($taxonomy);
2010 $term = get_term_by('slug', $default_folders[$taxonomy], $type);
2011 if ($default_folders[$taxonomy] == -1) {
2012 if($taxonomy == 'attachment'){
2013 $link = admin_url('upload.php?media_folder=-1');
2014 } else {
2015 $link = admin_url('edit.php?post_type=' . $taxonomy . '&' . $type . '=-1');
2016 }
2017 } else {
2018 if (!empty($term) && is_object($term)) {
2019 if($taxonomy == 'attachment'){
2020 $link = admin_url('upload.php?media_folder=' . $term->slug);
2021 }else{
2022 $link = admin_url('edit.php?post_type=' . $taxonomy . '&' . $type . '=' . $term->slug);
2023 }
2024 }
2025 }
2026 } else {
2027 if($taxonomy == 'attachment'){
2028 $link = admin_url('upload.php');
2029 } else {
2030 $link = admin_url('edit.php?post_type=' . $taxonomy);
2031 }
2032 }
2033 return $link;
2034 }
2035
2036 /**
2037 * Generates the admin URL link for a given taxonomy and term slug.
2038 *
2039 * @param string $taxonomy The taxonomy to generate the link for (e.g., post type or 'attachment').
2040 * @param string $term_slug The slug of the term within the taxonomy.
2041 * @return string The generated admin URL for the specified taxonomy and term slug.
2042 */
2043 function get_taxonomy_link($taxonomy, $term_slug)
2044 {
2045 $type = self::get_custom_post_type($taxonomy);
2046 if($taxonomy == 'attachment'){
2047 $link = admin_url('upload.php?media_folder=' . $term_slug);
2048 } else {
2049 $link = admin_url('edit.php?post_type=' . $taxonomy . '&' . $type . '=' . $term_slug);
2050 }
2051 return $link;
2052 }
2053
2054 /**
2055 * Filter input data
2056 *
2057 * @since 1.0.0
2058 * @access public
2059 * @return $folders
2060 */
2061 public function getRequestVar($var)
2062 {
2063 $response = filter_input(INPUT_POST, $var);
2064 if (empty($response)) {
2065 $response = filter_input(INPUT_GET, $var);
2066 }
2067
2068 return $response;
2069
2070 }//end getRequestVar()
2071
2072
2073 /**
2074 * Redirect to default folder
2075 *
2076 * @since 1.0.0
2077 * @access public
2078 * @return $folders
2079 */
2080 public function output_backbone_view_filters()
2081 {
2082 global $typenow, $current_screen;
2083 $minified = ".min";
2084 if(IS_FOLDERS_DEVELOPER_MODE) {
2085 $minified = "";
2086 }
2087 $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0;
2088 $options = get_option('folders_settings');
2089 $options = (empty($options) || !is_array($options)) ? [] : $options;
2090 $last_status = get_option("last_folder_status_for".$typenow);
2091 if (!$isAjax && (in_array($typenow, $options) || !empty($last_status)) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) {
2092 $default_folders = get_option('default_folders');
2093 $default_folders = (empty($default_folders) || !is_array($default_folders)) ? [] : $default_folders;
2094
2095 if (!empty($last_status)) {
2096 $status = 1;
2097 if ($last_status != "-1" && $last_status != "all") {
2098 $type = self::get_custom_post_type($typenow);
2099 $term = get_term_by('slug', $last_status, $type);
2100 if (empty($term) || !is_object($term)) {
2101 $status = 0;
2102 }
2103 }
2104
2105 delete_option("last_folder_status_for".$typenow);
2106 if ($last_status == "all") {
2107 $last_status = "";
2108 }
2109
2110 if ($status) {
2111 if ($typenow == "attachment") {
2112 if (!isset($_REQUEST['media_folder'])) {
2113 ?>
2114 <script>
2115 window.location = '<?php echo esc_url(admin_url("upload.php?post_type=attachment"))."&media_folder=".esc_attr($last_status) ?>';
2116 </script>
2117 <?php
2118 exit;
2119 }
2120 }
2121 }
2122 }//end if
2123
2124 $status = 1;
2125 if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
2126 $type = self::get_custom_post_type($typenow);
2127 if ($default_folders[$typenow] != -1) {
2128 $term = get_term_by('slug', $default_folders[$typenow], $type);
2129 if (empty($term) || !is_object($term)) {
2130 $status = 0;
2131 }
2132 }
2133 } else {
2134 $status = 0;
2135 }
2136
2137 if ($status) {
2138 if ($typenow == "attachment") {
2139 if (!isset($_REQUEST['media_folder'])) {
2140 if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
2141 ?>
2142 <script>
2143 window.location = '<?php echo esc_url(admin_url("upload.php?post_type=attachment"))."&media_folder=".esc_attr($default_folders[$typenow]) ?>';
2144 </script>
2145 <?php
2146 exit;
2147 }
2148 }
2149 }
2150 }
2151 }//end if
2152
2153 if (!(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media'))) {
2154 return;
2155 }
2156
2157 if ($typenow == "attachment") {
2158 // Free/Pro URL Change
2159 global $typenow;
2160 $is_active = 1;
2161 $folders = -1;
2162
2163 $hasStars = self::check_for_setting("has_stars", "general");
2164 $hasChild = self::check_for_setting("has_child", "general");
2165 $hasChild = empty($hasChild) ? 0 : 1;
2166 $hasStars = empty($hasStars) ? 0 : 1;
2167 // Free/Pro URL Change
2168 wp_enqueue_script('folders-media', WCP_FOLDER_URL.'assets/js/media'.esc_attr($minified).'.js', [ 'media-editor', 'media-views' ], WCP_FOLDER_VERSION, true);
2169 wp_localize_script(
2170 'folders-media',
2171 'folders_media_options',
2172 [
2173 'terms' => self::get_terms_hierarchical('media_folder'),
2174 'taxonomy' => get_taxonomy('media_folder'),
2175 'ajax_url' => admin_url("admin-ajax.php"),
2176 'activate_url' => $this->getFoldersUpgradeURL(),
2177 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
2178 'is_key_active' => $is_active,
2179 'hasStars' => $hasStars,
2180 'hasChildren' => $hasChild,
2181 'lang' => [
2182 "pro_message" => esc_html__("WordPress doesn't allow you to upload SVG files, upgrade to Folders Pro and experience added SVG file upload support!", "folders"),
2183 "activate_key" => esc_html__("Upgrade now!", "folders"),
2184 ]
2185 ]
2186 );
2187 // Free/Pro URL Change
2188 wp_enqueue_style('folders-media', WCP_FOLDER_URL.'assets/css/media.min.css', [], WCP_FOLDER_VERSION);
2189 } else if (!self::is_active_for_screen() && self::is_for_this_post_type('attachment')) {
2190
2191 $status = apply_filters("check_media_status_for_folders", true);
2192 if(!$status){
2193 return;
2194 }
2195
2196
2197 // Free/Pro URL Change
2198 global $current_screen;
2199 if (!isset($current_screen->base) || $current_screen->base != "plugins") {
2200 $is_active = 1;
2201 $folders = -1;
2202
2203 remove_filter("terms_clauses", "TO_apply_order_filter");
2204
2205 // Free/Pro URL Change
2206 $is_rtl = 0;
2207 if (function_exists('is_rtl') && is_rtl()) {
2208 $is_rtl = 1;
2209 }
2210
2211 $can_manage_folder = current_user_can("manage_categories") ? 1 : 0;
2212 $width = 275;
2213 $taxonomy_status = 0;
2214 $selected_taxonomy = "";
2215 $show_in_page = false;
2216 $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
2217
2218 $taxonomies = self::get_terms_hierarchical('media_folder');
2219
2220 $folder_settings = [];
2221 foreach ($taxonomies as $taxonomy) {
2222 $folder_info = get_term_meta($taxonomy->term_id, "folder_info", true);
2223 $folder_info = shortcode_atts([
2224 'is_sticky' => 0,
2225 'is_high' => 0,
2226 'is_locked' => 0,
2227 'is_active' => 0,
2228 'has_color' => ''
2229 ], $folder_info);
2230
2231 $folder_settings[] = [
2232 'folder_id' => $taxonomy->term_id,
2233 'is_sticky' => intval($folder_info['is_sticky']),
2234 'is_locked' => intval($folder_info['is_locked']),
2235 'is_active' => intval($folder_info['is_active']),
2236 'is_high' => intval($folder_info['is_high']),
2237 'has_color' => $folder_info['has_color'],
2238 'nonce' => wp_create_nonce('wcp_folder_term_'.$taxonomy->term_id),
2239 'is_deleted' => 0,
2240 'slug' => $taxonomy->slug,
2241 'folder_count' => intval($taxonomy->trash_count),
2242 ];
2243 }
2244
2245 $hasStars = self::check_for_setting("has_stars", "general");
2246 $hasChild = self::check_for_setting("has_child", "general");
2247 $hasChild = empty($hasChild) ? 0 : 1;
2248 $hasStars = empty($hasStars) ? 0 : 1;
2249
2250 $customize_folders = get_option('customize_folders');
2251 $customize_folders = (empty($customize_folders)||!is_array($customize_folders))?[]:$customize_folders;
2252 $use_folder_undo = !isset($customize_folders['use_folder_undo']) ? "yes" : $customize_folders['use_folder_undo'];
2253 $defaultTimeout = !isset($customize_folders['default_timeout']) ? 5 : intval($customize_folders['default_timeout']);
2254 if (empty($defaultTimeout) || !is_numeric($defaultTimeout) || $defaultTimeout < 0) {
2255 $defaultTimeout = 5;
2256 }
2257
2258 $defaultTimeout = ($defaultTimeout * 1000);
2259
2260 $default_folders = get_option("default_folders");
2261 $default_folder = "";
2262 if (isset($default_folders["attachment"])) {
2263 $default_folder = $default_folders["attachment"];
2264 }
2265
2266 $use_shortcuts = !isset($customize_folders['use_shortcuts']) ? "yes" : $customize_folders['use_shortcuts'];
2267
2268 $custom_sort = isset($customize_folders['force_sorting'])?$customize_folders['force_sorting']:"off";
2269 $current_sort = "";
2270 if($custom_sort != "on") {
2271 $custom_sort = "off";
2272 } else {
2273 $current_sort = get_option("wcp_custom_sort_attachment", "");
2274 }
2275
2276 ob_start();
2277 include_once dirname(dirname(__FILE__)).WCP_DS."/templates".WCP_DS."admin".WCP_DS."modals.php";
2278 $form_content = ob_get_clean();
2279
2280 $lang = $this->js_strings();
2281 wp_dequeue_script("jquery-jstree");
2282 // CMS Tree Page View Conflict
2283 wp_enqueue_script('folders-overlayscrollbars', WCP_FOLDER_URL.'assets/js/jquery.overlayscrollbars.min.js', [], WCP_FOLDER_VERSION, true);
2284 wp_enqueue_script('folders-tree', WCP_FOLDER_URL.'assets/js/jstree.min.js', [], WCP_FOLDER_VERSION, true);
2285 wp_enqueue_script('wcp-folders-media', WCP_FOLDER_URL.'assets/js/page-post-media'.esc_attr($minified).'.js', ['jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'], WCP_FOLDER_VERSION, true);
2286 wp_enqueue_script('wcp-jquery-touch', plugin_dir_url(dirname(__FILE__)).'assets/js/jquery.ui.touch-punch.min.js', ['jquery'], WCP_FOLDER_VERSION, true);
2287 wp_localize_script(
2288 'wcp-folders-media',
2289 'folders_media_options',
2290 [
2291 'terms' => $taxonomies,
2292 'taxonomy' => get_taxonomy('media_folder'),
2293 'ajax_url' => admin_url("admin-ajax.php"),
2294 'media_page_url' => admin_url("upload.php?media_folder="),
2295 'activate_url' => $this->getFoldersUpgradeURL(),
2296 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
2297 'is_key_active' => $is_active,
2298 'folders' => $folders,
2299 'upgrade_url' => $this->getFoldersUpgradeURL(),
2300 'post_type' => 'attachment',
2301 'page_url' => $admin_url,
2302 'current_url' => "",
2303 'ajax_image' => plugin_dir_url(dirname(__FILE__))."assets/images/ajax-loader.gif",
2304 'register_url' => "",
2305 'isRTL' => $is_rtl,
2306 'can_manage_folder' => $can_manage_folder,
2307 'folder_width' => $width,
2308 'taxonomy_status' => $taxonomy_status,
2309 'selected_taxonomy' => $selected_taxonomy,
2310 'show_in_page' => $show_in_page,
2311 'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png',
2312 'folder_settings' => $folder_settings,
2313 'hasStars' => $hasStars,
2314 'hasChildren' => $hasChild,
2315 'useFolderUndo' => $use_folder_undo,
2316 'defaultTimeout' => $defaultTimeout,
2317 'default_folder' => $default_folder,
2318 'use_shortcuts' => $use_shortcuts,
2319 'lang' => $lang,
2320 'selected_colors' => $this->selected_colors(),
2321 'form_content' => $form_content,
2322 'custom_sort' => $custom_sort,
2323 'current_sort' => $current_sort
2324 ]
2325 );
2326 // Free/Pro URL Change
2327 wp_enqueue_style('folders-jstree', WCP_FOLDER_URL.'assets/css/jstree.min.css', [], WCP_FOLDER_VERSION);
2328 wp_enqueue_style('folder-overlayscrollbars', WCP_FOLDER_URL.'assets/css/overlayscrollbars.min.css', [], WCP_FOLDER_VERSION);
2329 wp_enqueue_style('folder-folders', WCP_FOLDER_URL.'assets/css/folders'.esc_attr($minified).'.css', [], WCP_FOLDER_VERSION);
2330 wp_enqueue_style('folders-media', WCP_FOLDER_URL.'assets/css/page-post-media'.esc_attr($minified).'.css', [], WCP_FOLDER_VERSION);
2331 wp_enqueue_style('folder-icon', WCP_FOLDER_URL.'assets/css/folder-icon.min.css', [], WCP_FOLDER_VERSION);
2332 $width = 275;
2333 $string = "";
2334 $css_text = "";
2335 $customize_folders = get_option('customize_folders');
2336 $customize_folders = is_array($customize_folders)?$customize_folders:[];
2337 if (!isset($customize_folders['new_folder_color']) || empty($customize_folders['new_folder_color'])) {
2338 $customize_folders['new_folder_color'] = "#FA166B";
2339 }
2340
2341 $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'])."}";
2342 $css_text .= ".wcp-hide-show-buttons .toggle-buttons { background-color: ".esc_attr($customize_folders['new_folder_color'])."; }";
2343 $css_text .= ".folders-toggle-button span { background-color: ".esc_attr($customize_folders['new_folder_color'])."; }";
2344 $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}";
2345
2346 if (!isset($customize_folders['folder_bg_color']) || empty($customize_folders['folder_bg_color'])) {
2347 $customize_folders['folder_bg_color'] = "#FA166B";
2348 }
2349 if (!isset($customize_folders['default_icon_color']) || empty($customize_folders['default_icon_color'])) {
2350 $customize_folders['default_icon_color'] = "#334155";
2351 }
2352
2353 $rgbColor = self::hexToRgb($customize_folders['folder_bg_color']);
2354 $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked), body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked):hover { background: rgba(".esc_attr($rgbColor['r']).",".esc_attr($rgbColor['g']).",".esc_attr($rgbColor['b']).", 0.08) !important; color: #333333;}";
2355 $css_text .= ".dynamic-menu li.color-folder:hover { background: rgba(".$rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08) !important; }";
2356 $css_text .= "body:not(.no-hover-css) .dynamic-menu li.color-folder a:hover { background: transparent !important;}";
2357 $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked, body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked:not(.jstree-clicked):focus, #custom-scroll-menu .jstree-clicked, #custom-scroll-menu .jstree-clicked:hover { background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff !important; }";
2358 $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked .folder-actions { background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff !important; }";
2359 $css_text .= "#custom-scroll-menu .jstree-hovered.wcp-drop-hover, #custom-scroll-menu .jstree-hovered.wcp-drop-hover:hover, #custom-scroll-menu .jstree-clicked.wcp-drop-hover, #custom-scroll-menu .jstree-clicked.wcp-drop-hover:hover, body #custom-scroll-menu *.drag-in >, body #custom-scroll-menu *.drag-in > a:hover { background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff !important; }";
2360 $css_text .= ".drag-bot > a { border-bottom: solid 2px ".esc_attr($customize_folders['folder_bg_color'])."}";
2361 $css_text .= ".drag-up > a { border-top: solid 2px ".esc_attr($customize_folders['folder_bg_color'])."}";
2362 $css_text .= "body:not(.no-hover-css) #custom-scroll-menu *.drag-in > a.jstree-hovered, body:not(.no-hover-css) #custom-scroll-menu *.drag-in > a.jstree-hovered:hover {background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #fff !important;}";
2363 $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; }";
2364 $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;}";
2365 $css_text .= ".wcp-drop-hover {background-color: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff; }";
2366 $css_text .= "#custom-menu .route .nav-icon .wcp-icon {color: ".esc_attr($customize_folders['folder_bg_color'])." !important;}";
2367 $css_text .= ".mCS-3d.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar {background-color: ".esc_attr($customize_folders['folder_bg_color'])." !important;}";
2368 $css_text .= ".os-theme-dark>.os-scrollbar>.os-scrollbar-track>.os-scrollbar-handle {background-color: ".esc_attr($customize_folders['folder_bg_color'])." !important;}";
2369 $css_text .= "body:not(.no-hover-css) .jstree-hovered {background: rgba(".esc_attr($rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08").") }";
2370 $css_text .= ".jstree-default .jstree-clicked { background-color:".esc_attr($customize_folders['folder_bg_color'])."}";
2371 $css_text .= ".jstree-node.drag-in > a.jstree-anchor.jstree-hovered { background-color: ".esc_attr($customize_folders['folder_bg_color'])."; color: #ffffff; }";
2372 $css_text .= "#custom-scroll-menu .jstree-hovered:not(.jstree-clicked) .pfolder-folder-close { color: ".esc_attr($customize_folders['folder_bg_color'])."; }";
2373 $css_text .= ".pfolder-folder-close {color: ".esc_attr($customize_folders['default_icon_color'])."}";
2374 if (!isset($customize_folders['bulk_organize_button_color']) || empty($customize_folders['bulk_organize_button_color'])) {
2375 $customize_folders['bulk_organize_button_color'] = "#FA166B";
2376 }
2377
2378 $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'])."; }";
2379 $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'])."; }";
2380
2381 $font_family = "";
2382 if (isset($customize_folders['folder_font']) && !empty($customize_folders['folder_font'])) {
2383 $folder_fonts = self::get_font_list();
2384 $font_family = $customize_folders['folder_font'];
2385 if (isset($folder_fonts[$font_family])) {
2386 $css_text .= ".wcp-container, .folder-popup-form { font-family: ".esc_attr($font_family)." !important; }";
2387 }
2388
2389 if ($folder_fonts[$font_family] == "Default") {
2390 $font_family = "";
2391 }
2392 }
2393
2394 if (isset($customize_folders['folder_size']) && !empty($customize_folders['folder_size'])) {
2395 $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; }";
2396 }
2397
2398 if (!empty($font_family)) {
2399 wp_enqueue_style('custom-google-fonts', 'https://fonts.googleapis.com/css?family='.urlencode($font_family), false);
2400 }
2401
2402 wp_add_inline_style('folders-media', $css_text);
2403 }//end if
2404 }//end if
2405
2406 }//end output_backbone_view_filters()
2407
2408
2409 /**
2410 * Get folders by hierarchy
2411 *
2412 * @since 1.0.0
2413 * @access public
2414 * @return $folders
2415 */
2416 public function get_terms_hierarchical($taxonomy)
2417 {
2418 $terms = get_terms(
2419 [
2420 'taxonomy' => $taxonomy,
2421 'hide_empty' => false,
2422 'parent' => 0,
2423 'orderby' => 'meta_value_num',
2424 'order' => 'ASC',
2425 'hierarchical' => false,
2426 'update_count_callback' => '_update_generic_term_count',
2427 'meta_query' => [
2428 [
2429 'key' => 'wcp_custom_order',
2430 'type' => 'NUMERIC',
2431 ],
2432 ],
2433 ]
2434 );
2435 $hierarchical_terms = [];
2436 if (!empty($terms)) {
2437 foreach ($terms as $term) {
2438 if (!empty($term) && isset($term->term_id)) {
2439 $term->term_name = $term->name;
2440 $hierarchical_terms[] = $term;
2441 $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, "-");
2442 }
2443 }
2444 }
2445
2446 return $hierarchical_terms;
2447
2448 }//end get_terms_hierarchical()
2449
2450
2451 /**
2452 * Get Child folders
2453 *
2454 * @since 1.0.0
2455 * @access public
2456 * @return $folders
2457 */
2458 public static function get_child_terms($taxonomy, $hierarchical_terms, $term_id, $separator="-")
2459 {
2460 $terms = get_terms(
2461 [
2462 'taxonomy' => $taxonomy,
2463 'hide_empty' => false,
2464 'parent' => $term_id,
2465 'orderby' => 'meta_value_num',
2466 'order' => 'ASC',
2467 'hierarchical' => false,
2468 'update_count_callback' => '_update_generic_term_count',
2469 'meta_query' => [
2470 [
2471 'key' => 'wcp_custom_order',
2472 'type' => 'NUMERIC',
2473 ],
2474 ],
2475 ]
2476 );
2477 if (!empty($terms)) {
2478 foreach ($terms as $term) {
2479 if (isset($term->name)) {
2480 $term->name = $separator." ".$term->name;
2481 $term->term_name = trim($term->name, "-");
2482 $hierarchical_terms[] = $term;
2483 $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, $separator."-");
2484 }
2485 }
2486 }
2487
2488 return $hierarchical_terms;
2489
2490 }//end get_child_terms()
2491
2492
2493 /**
2494 * Update folders data for page, post, media
2495 *
2496 * @since 1.0.0
2497 * @access public
2498 * @return $folders
2499 */
2500 public function update_folder_new_term_relationships($object_id="", $term_ids=[], $taxonomy="")
2501 {
2502 if (is_array($term_ids) && !empty($term_ids)) {
2503 $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
2504 if ($trash_folders === false) {
2505 $trash_folders = [];
2506 $initial_trash_folders = [];
2507 }
2508
2509 foreach ($term_ids as $term_id) {
2510 $term = get_term($term_id, $taxonomy);
2511 if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) {
2512 unset($trash_folders[$term->term_taxonomy_id]);
2513 }
2514 }
2515
2516 if ($initial_trash_folders != $trash_folders) {
2517 delete_transient("premio_folders_without_trash");
2518 set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
2519 }
2520 }
2521
2522 }//end update_folder_new_term_relationships()
2523
2524
2525 /**
2526 * Update folders data for page, post, media
2527 *
2528 * @since 1.0.0
2529 * @access public
2530 * @return $folders
2531 */
2532 public function update_folder_term_relationships($object_id="", $term_ids=[], $taxonomy="")
2533 {
2534 if (is_array($term_ids) && !empty($term_ids)) {
2535 $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
2536 if ($trash_folders === false) {
2537 $trash_folders = [];
2538 $initial_trash_folders = [];
2539 }
2540
2541 foreach ($term_ids as $term_id) {
2542 $term = get_term($term_id, $taxonomy);
2543 if (isset($term->term_taxonomy_id) && isset($trash_folders[$term_id])) {
2544 unset($trash_folders[$term->term_taxonomy_id]);
2545 }
2546 }
2547
2548 if ($initial_trash_folders != $trash_folders) {
2549 delete_transient("premio_folders_without_trash");
2550 set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
2551 }
2552 }
2553
2554 }//end update_folder_term_relationships()
2555
2556
2557 /**
2558 * Get child folders
2559 *
2560 * @since 1.0.0
2561 * @access public
2562 * @return $folders
2563 */
2564 private function add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $current_term_id, $current_depth)
2565 {
2566
2567 if (! isset($hierarchy[$current_term_id])) {
2568 return $hierarchical_terms;
2569 }
2570
2571 foreach ($hierarchy[$current_term_id] as $child_term_id) {
2572 $child_term = get_term($child_term_id, $taxonomy);
2573
2574 $child_term->name = str_pad('', $current_depth, '-', STR_PAD_LEFT).' '.$child_term->name;
2575
2576 $hierarchical_terms[] = $child_term;
2577
2578 $hierarchical_terms = self::add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $child_term_id, ( $current_depth + 1 ));
2579 }
2580
2581 return $hierarchical_terms;
2582
2583 }//end add_child_terms_recursive()
2584
2585
2586 /**
2587 * Filter data for attachments
2588 *
2589 * @since 1.0.0
2590 * @access public
2591 * @return $folders
2592 */
2593 public function filter_attachments_list($query)
2594 {
2595
2596 if (! isset($query->query['post_type'])) {
2597 return $query;
2598 }
2599
2600 if (is_array($query->query['post_type']) && ! in_array('attachment', $query->query['post_type'])) {
2601 return $query;
2602 }
2603
2604 if (! is_array($query->query['post_type']) && strpos($query->query['post_type'], 'attachment') === false) {
2605 return $query;
2606 }
2607
2608 if (! isset($_REQUEST['media_folder'])) {
2609 return $query;
2610 }
2611
2612 $term = sanitize_text_field(wp_unslash($_REQUEST['media_folder']));
2613 if ($term != "-1") {
2614 return $query;
2615 }
2616
2617 unset($query->query_vars['media_folder']);
2618
2619 $tax_query = [
2620 'taxonomy' => 'media_folder',
2621 'operator' => 'NOT EXISTS',
2622 ];
2623
2624 $query->set('tax_query', [ $tax_query ]);
2625 $query->tax_query = new WP_Tax_Query([ $tax_query ]);
2626
2627 $query = apply_filters('media_library_organizer_media_filter_attachments', $query, $_REQUEST);
2628
2629 return $query;
2630
2631 }//end filter_attachments_list()
2632
2633
2634 /**
2635 * Filter data for attachments
2636 *
2637 * @since 1.0.0
2638 * @access public
2639 * @return $folders
2640 */
2641 public function output_list_table_filters($post_type, $view_name = "")
2642 {
2643 if ($post_type != 'attachment') {
2644 return;
2645 }
2646
2647 if ($view_name != 'bar') {
2648 return;
2649 }
2650
2651 if (!self::is_for_this_post_type('attachment')) {
2652 return;
2653 }
2654
2655 $current_term = false;
2656 if (isset($_REQUEST['media_folder'])) {
2657 $current_term = sanitize_text_field($_REQUEST['media_folder']);
2658 }
2659
2660 wp_dropdown_categories(
2661 [
2662 'show_option_all' => esc_html__('All Folders', 'folders'),
2663 'show_option_none' => esc_html__('(Unassigned)', 'folders'),
2664 'option_none_value' => -1,
2665 'orderby' => 'meta_value_num',
2666 'order' => 'ASC',
2667 'show_count' => true,
2668 'hide_empty' => false,
2669 'update_count_callback' => '_update_generic_term_count',
2670 'echo' => true,
2671 'selected' => $current_term,
2672 'hierarchical' => true,
2673 'name' => 'media_folder',
2674 'id' => '',
2675 'class' => '',
2676 'taxonomy' => 'media_folder',
2677 'value_field' => 'slug',
2678 'meta_query' => [
2679 [
2680 'key' => 'wcp_custom_order',
2681 'type' => 'NUMERIC',
2682 ],
2683 ],
2684 ]
2685 );
2686
2687 }//end output_list_table_filters()
2688
2689
2690 /**
2691 * Update folder relationship with page, post, media
2692 *
2693 * @since 1.0.0
2694 * @access public
2695 * @return $folders
2696 */
2697 function new_to_auto_draft($post)
2698 {
2699
2700 $post_type = $post->post_type;
2701
2702 if (self::is_for_this_post_type($post_type) && !isset($_REQUEST["folder_for_media"])) {
2703 $post_type = self::get_custom_post_type($post_type);
2704 $selected_folder = get_option("selected_".esc_attr($post_type)."_folder");
2705
2706 if ($selected_folder != null && !empty($selected_folder)) {
2707 $terms = get_term($selected_folder);
2708 if (!empty($terms) && isset($terms->slug)) {
2709 wp_set_object_terms($post->ID, $terms->slug, $post_type);
2710 }
2711 }
2712 }
2713
2714 }//end new_to_auto_draft()
2715
2716
2717 /**
2718 * Send message to owner for Help
2719 *
2720 * @since 1.0.0
2721 * @access public
2722 * @return $response
2723 */
2724 public function wcp_folder_send_message_to_owner()
2725 {
2726 if (current_user_can('manage_options')) {
2727 $response = [];
2728 $response['status'] = 0;
2729 $response['error'] = 0;
2730 $response['errors'] = [];
2731 $response['message'] = "";
2732 $errorArray = [];
2733 $errorMessage = esc_html__("%\$s is required", 'folders');
2734 $postData = filter_input_array(INPUT_POST);
2735 if (!isset($postData['textarea_text']) || trim($postData['textarea_text']) == "") {
2736 $error = [
2737 "key" => "textarea_text",
2738 "message" => esc_html__("Please enter your message", 'folders'),
2739 ];
2740 $errorArray[] = $error;
2741 }
2742
2743 if (!isset($postData['user_email']) || trim($postData['user_email']) == "") {
2744 $error = [
2745 "key" => "user_email",
2746 "message" => sprintf($errorMessage, __("Email", 'folders')),
2747 ];
2748 $errorArray[] = $error;
2749 } else if (!filter_var($postData['user_email'], FILTER_VALIDATE_EMAIL)) {
2750 $error = [
2751 'key' => "user_email",
2752 "message" => "Email is not valid",
2753 ];
2754 $errorArray[] = $error;
2755 }
2756
2757 if (empty($errorArray)) {
2758 if (!isset($postData['folder_help_nonce']) || trim($postData['folder_help_nonce']) == "") {
2759 $error = [
2760 "key" => "nonce",
2761 "message" => esc_html__("Your request is not valid", 'folders'),
2762 ];
2763 $errorArray[] = $error;
2764 } else {
2765 if (!wp_verify_nonce($postData['folder_help_nonce'], 'wcp_folder_help_nonce')) {
2766 $error = [
2767 "key" => "nonce",
2768 "message" => esc_html__("Your request is not valid", 'folders'),
2769 ];
2770 $errorArray[] = $error;
2771 }
2772 }
2773 }
2774
2775 if (empty($errorArray)) {
2776 $text_message = self::sanitize_options($postData['textarea_text']);
2777 $email = self::sanitize_options($postData['user_email'], "email");
2778 $domain = site_url();
2779 $current_user = wp_get_current_user();
2780 $user_name = $current_user->first_name." ".$current_user->last_name;
2781
2782 $response['status'] = 1;
2783
2784 // sending message to Crisp
2785 $post_message = [];
2786
2787 $message_data = [];
2788 $message_data['key'] = "Plugin";
2789 $message_data['value'] = "Folders";
2790 $post_message[] = $message_data;
2791
2792 $message_data = [];
2793 $message_data['key'] = "Domain";
2794 $message_data['value'] = $domain;
2795 $post_message[] = $message_data;
2796
2797 $message_data = [];
2798 $message_data['key'] = "Email";
2799 $message_data['value'] = $email;
2800 $post_message[] = $message_data;
2801
2802 $message_data = [];
2803 $message_data['key'] = "Message";
2804 $message_data['value'] = $text_message;
2805 $post_message[] = $message_data;
2806
2807 $api_params = [
2808 'domain' => $domain,
2809 'email' => $email,
2810 'url' => site_url(),
2811 'name' => $user_name,
2812 'message' => $post_message,
2813 'plugin' => "Folders",
2814 'type' => "Need Help",
2815 ];
2816
2817 // Sending message to Crisp API
2818 $crisp_response = wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => true]);
2819
2820 if (is_wp_error($crisp_response)) {
2821 wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => false]);
2822 }
2823 } else {
2824 $response['error'] = 1;
2825 $response['errors'] = $errorArray;
2826 }//end if
2827
2828 echo wp_json_encode($response);
2829 }//end if
2830
2831 }//end wcp_folder_send_message_to_owner()
2832
2833
2834 /**
2835 * Send message to owner when folder is deactivated
2836 *
2837 * @since 1.0.0
2838 * @access public
2839 * @return $response
2840 */
2841 public function folder_plugin_deactivate()
2842 {
2843 if (current_user_can('manage_options')) {
2844 $postData = filter_input_array(INPUT_POST);
2845 $errorCounter = 0;
2846 $response = [];
2847 $response['status'] = 0;
2848 $response['message'] = "";
2849 $response['valid'] = 1;
2850 if (!isset($postData['reason']) || empty($postData['reason'])) {
2851 $errorCounter++;
2852 $response['message'] = "Please provide reason";
2853 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2854 $response['message'] = esc_html__("Your request is not valid", 'folders');
2855 $errorCounter++;
2856 $response['valid'] = 0;
2857 } else {
2858 $nonce = self::sanitize_options($postData['nonce']);
2859 if (!wp_verify_nonce($nonce, 'wcp_folder_deactivate_nonce')) {
2860 $response['message'] = esc_html__("Your request is not valid", 'folders');
2861 $errorCounter++;
2862 $response['valid'] = 0;
2863 }
2864 }
2865
2866 if ($errorCounter == 0) {
2867 $reason = $postData['reason'];
2868 $email = "none@none.none";
2869 if (isset($postData['email_id']) && !empty($postData['email_id']) && filter_var($postData['email_id'], FILTER_VALIDATE_EMAIL)) {
2870 $email = $postData['email_id'];
2871 }
2872
2873 $domain = site_url();
2874 $current_user = wp_get_current_user();
2875 $user_name = $current_user->first_name." ".$current_user->last_name;
2876
2877 $response['status'] = 1;
2878
2879 // sending message to Crisp
2880 $post_message = [];
2881
2882 $message_data = [];
2883 $message_data['key'] = "Plugin";
2884 $message_data['value'] = "Folders";
2885 $post_message[] = $message_data;
2886
2887 $message_data = [];
2888 $message_data['key'] = "Plugin Version";
2889 $message_data['value'] = WCP_FOLDER_VERSION;
2890 $post_message[] = $message_data;
2891
2892 $message_data = [];
2893 $message_data['key'] = "Domain";
2894 $message_data['value'] = $domain;
2895 $post_message[] = $message_data;
2896
2897 $message_data = [];
2898 $message_data['key'] = "Email";
2899 $message_data['value'] = $email;
2900 $post_message[] = $message_data;
2901
2902 $message_data = [];
2903 $message_data['key'] = "WordPress Version";
2904 $message_data['value'] = esc_attr(get_bloginfo('version'));
2905 $post_message[] = $message_data;
2906
2907 $message_data = [];
2908 $message_data['key'] = "PHP Version";
2909 $message_data['value'] = PHP_VERSION;
2910 $post_message[] = $message_data;
2911
2912 $message_data = [];
2913 $message_data['key'] = "Message";
2914 $message_data['value'] = $reason;
2915 $post_message[] = $message_data;
2916
2917 $api_params = [
2918 'domain' => $domain,
2919 'email' => $email,
2920 'url' => site_url(),
2921 'name' => $user_name,
2922 'message' => $post_message,
2923 'plugin' => "Folders",
2924 'type' => "Uninstall",
2925 ];
2926
2927 // Sending message to Crisp API
2928 $crisp_response = wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => true]);
2929
2930 if (is_wp_error($crisp_response)) {
2931 wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => false]);
2932 }
2933 }//end if
2934
2935 echo wp_json_encode($response);
2936 wp_die();
2937 }//end if
2938
2939 }//end folder_plugin_deactivate()
2940
2941
2942 /**
2943 * Returns total folders
2944 *
2945 * @since 1.0.0
2946 * @access public
2947 * @return $total
2948 */
2949 public static function ttl_fldrs()
2950 {
2951 $post_types = get_option('folders_settings');
2952 $post_types = is_array($post_types) ? $post_types : [];
2953 $total = 0;
2954 foreach ($post_types as $post_type) {
2955 $post_type = self::get_custom_post_type($post_type);
2956 $total += wp_count_terms($post_type);
2957 }
2958
2959 return $total;
2960
2961 }//end ttl_fldrs()
2962
2963
2964 /**
2965 * Remove post
2966 *
2967 * @since 1.0.0
2968 * @access public
2969 * @return $response
2970 */
2971 public function wcp_remove_post_item()
2972 {
2973 $response = [];
2974 $response['status'] = 0;
2975 $response['error'] = 0;
2976 $response['data'] = [];
2977 $response['message'] = "";
2978 $postData = filter_input_array(INPUT_POST);
2979 if (isset($postData['post_id']) && !empty($postData['post_id'])) {
2980 wp_delete_post($postData['post_id']);
2981 $response['status'] = 1;
2982 }
2983
2984 echo wp_json_encode($response);
2985 wp_die();
2986
2987 }//end wcp_remove_post_item()
2988
2989
2990 /**
2991 * Mark all folders
2992 *
2993 * @since 1.0.0
2994 * @access public
2995 * @return $response
2996 */
2997 public function wcp_change_all_status()
2998 {
2999 $response = [];
3000 $response['status'] = 0;
3001 $response['error'] = 0;
3002 $response['data'] = [];
3003 $response['message'] = "";
3004 $postData = filter_input_array(INPUT_POST);
3005 $errorCounter = 0;
3006 if (!isset($postData['type']) || empty($postData['type'])) {
3007 $response['message'] = esc_html__("Your request is not valid", 'folders');
3008 $errorCounter++;
3009 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3010 $response['message'] = esc_html__("Your request is not valid", 'folders');
3011 $errorCounter++;
3012 } else if (!current_user_can("manage_categories") || ($postData['type'] == "page" && !current_user_can("edit_pages"))) {
3013 $response['message'] = esc_html__("You have not permission to update width", 'folders');
3014 $errorCounter++;
3015 } else if (!current_user_can("manage_categories") || ($postData['type'] != "page" && !current_user_can("edit_posts"))) {
3016 $response['message'] = esc_html__("You have not permission to update width", 'folders');
3017 $errorCounter++;
3018 } else {
3019 $type = self::sanitize_options($postData['type']);
3020 $nonce = self::sanitize_options($postData['nonce']);
3021 if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
3022 $response['message'] = esc_html__("Your request is not valid", 'folders');
3023 $errorCounter++;
3024 }
3025 }
3026
3027 if ($errorCounter == 0) {
3028 if (isset($postData['folders']) || !empty($postData['folders'])) {
3029 $status = isset($postData['status']) ? $postData['status'] : 0;
3030 $status = self::sanitize_options($status);
3031 $folders = self::sanitize_options($postData['folders']);
3032 $folders = trim($folders, ",");
3033 $folders = explode(",", $folders);
3034 foreach ($folders as $folder) {
3035 update_term_meta($folder, "is_active", $status);
3036 }
3037 }
3038
3039 $response['status'] = 1;
3040 }
3041
3042 echo wp_json_encode($response);
3043 wp_die();
3044
3045 }//end wcp_change_all_status()
3046
3047
3048 /**
3049 * Change folder width
3050 *
3051 * @since 1.0.0
3052 * @access public
3053 * @return $response
3054 */
3055 public function wcp_change_post_width()
3056 {
3057 $response = [];
3058 $response['status'] = 0;
3059 $response['error'] = 0;
3060 $response['data'] = [];
3061 $response['message'] = "";
3062 $postData = filter_input_array(INPUT_POST);
3063 $errorCounter = 0;
3064 if (!isset($postData['width']) || empty($postData['width'])) {
3065 $response['message'] = esc_html__("Your request is not valid", 'folders');
3066 $errorCounter++;
3067 } else if (!isset($postData['type']) || empty($postData['type'])) {
3068 $response['message'] = esc_html__("Your request is not valid", 'folders');
3069 $errorCounter++;
3070 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3071 $response['message'] = esc_html__("Your request is not valid", 'folders');
3072 $errorCounter++;
3073 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
3074 $response['message'] = esc_html__("You have not permission to update width", 'folders');
3075 $errorCounter++;
3076 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
3077 $response['message'] = esc_html__("You have not permission to update width", 'folders');
3078 $errorCounter++;
3079 } else {
3080 $type = self::sanitize_options($postData['type']);
3081 $nonce = self::sanitize_options($postData['nonce']);
3082 if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
3083 $response['message'] = esc_html__("Your request is not valid", 'folders');
3084 $errorCounter++;
3085 }
3086 }//end if
3087
3088 if ($errorCounter == 0) {
3089 $type = self::sanitize_options($postData['type']);
3090 $width = self::sanitize_options($postData['width'], "int");
3091 $optionName = "wcp_dynamic_width_for_".$type;
3092 update_option($optionName, $width);
3093 $response['status'] = 1;
3094 }
3095
3096 echo wp_json_encode($response);
3097 wp_die();
3098
3099 }//end wcp_change_post_width()
3100
3101
3102 /**
3103 * Assign folder to multiple posts, pages, attachments
3104 *
3105 * @since 1.0.0
3106 * @access public
3107 * @return $response
3108 */
3109 public function wcp_change_multiple_post_folder()
3110 {
3111 $response = [];
3112 $response['status'] = 0;
3113 $response['error'] = 0;
3114 $response['data'] = [];
3115 $response['message'] = "";
3116 $postData = filter_input_array(INPUT_POST);
3117 $errorCounter = 0;
3118 if (!isset($postData['post_ids']) || empty($postData['post_ids'])) {
3119 $response['message'] = esc_html__("Your request is not valid", 'folders');
3120 $errorCounter++;
3121 } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
3122 $response['message'] = esc_html__("Your request is not valid", 'folders');
3123 $errorCounter++;
3124 } else if (!isset($postData['type']) || empty($postData['type'])) {
3125 $response['message'] = esc_html__("Your request is not valid", 'folders');
3126 $errorCounter++;
3127 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3128 $response['message'] = esc_html__("Your request is not valid", 'folders');
3129 $errorCounter++;
3130 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
3131 $response['message'] = esc_html__("You have not permission to update folder", 'folders');
3132 $errorCounter++;
3133 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
3134 $response['message'] = esc_html__("You have not permission to update folder", 'folders');
3135 $errorCounter++;
3136 } else {
3137 $folder_id = self::sanitize_options($postData['folder_id']);
3138 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$folder_id)) {
3139 $response['message'] = esc_html__("Your request is not valid", 'folders');
3140 $errorCounter++;
3141 }
3142 }//end if
3143
3144 if ($errorCounter == 0) {
3145 $folderUndoSettings = [];
3146 $postID = self::sanitize_options($postData['post_ids']);
3147 $postID = trim($postID, ",");
3148 $folderID = self::sanitize_options($postData['folder_id']);
3149 $type = self::sanitize_options($postData['type']);
3150 $postArray = explode(",", $postID);
3151 $status = 0;
3152 if (isset($postData['status'])) {
3153 $status = self::sanitize_options($postData['status']);
3154 }
3155
3156 $status = true;
3157
3158 $taxonomy = "";
3159 if (isset($postData['taxonomy'])) {
3160 $taxonomy = self::sanitize_options($postData['taxonomy']);
3161 }
3162
3163 if (is_array($postArray)) {
3164 $post_type = self::get_custom_post_type($type);
3165 foreach ($postArray as $post) {
3166 $terms = get_the_terms($post, $post_type);
3167 $post_terms = [
3168 'post_id' => $post,
3169 'terms' => $terms,
3170 ];
3171 $folderUndoSettings[] = $post_terms;
3172 if (!empty($terms)) {
3173 foreach ($terms as $term) {
3174 if (!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
3175 wp_remove_object_terms($post, $term->term_id, $post_type);
3176 }
3177 }
3178 }
3179
3180 wp_set_post_terms($post, $folderID, $post_type, $status);
3181 }
3182 }
3183
3184 $response['status'] = 1;
3185 delete_transient("folder_undo_settings");
3186 delete_transient("premio_folders_without_trash");
3187 set_transient("folder_undo_settings", $folderUndoSettings, DAY_IN_SECONDS);
3188
3189 if(!get_option("show_folder_upgrade_popup")) {
3190 add_option("show_folder_upgrade_popup", "hide");
3191 }
3192 }//end if
3193
3194 echo wp_json_encode($response);
3195 wp_die();
3196
3197 }//end wcp_change_multiple_post_folder()
3198
3199
3200 /**
3201 * Undo folder changes
3202 *
3203 * @since 1.0.0
3204 * @access public
3205 * @return $response
3206 */
3207 public function wcp_undo_folder_changes()
3208 {
3209 $response = [];
3210 $response['status'] = 0;
3211 $response['error'] = 0;
3212 $response['data'] = [];
3213 $response['message'] = "";
3214 $postData = filter_input_array(INPUT_POST);
3215 $errorCounter = 0;
3216 if (!isset($postData['post_type']) || empty($postData['post_type'])) {
3217 $response['message'] = esc_html__("Your request is not valid", 'folders');
3218 $errorCounter++;
3219 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3220 $response['message'] = esc_html__("Your request is not valid", 'folders');
3221 $errorCounter++;
3222 } else {
3223 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['post_type'])) {
3224 $response['message'] = esc_html__("Your request is not valid", 'folders');
3225 $errorCounter++;
3226 }
3227 }
3228
3229 if ($errorCounter == 0) {
3230 $response['status'] = 1;
3231 $folder_undo_settings = get_transient("folder_undo_settings");
3232 $type = self::sanitize_options($postData['post_type']);
3233 $post_type = self::get_custom_post_type($type);
3234 if (!empty($folder_undo_settings) && is_array($folder_undo_settings)) {
3235 $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash");
3236 if ($trash_folders === false) {
3237 $trash_folders = [];
3238 $initial_trash_folders = [];
3239 }
3240
3241 foreach ($folder_undo_settings as $item) {
3242 $terms = get_the_terms($item['post_id'], $post_type);
3243 if (!empty($terms)) {
3244 foreach ($terms as $term) {
3245 wp_remove_object_terms($item['post_id'], $term->term_id, $post_type);
3246 if (isset($trash_folders[$term->term_taxonomy_id])) {
3247 unset($trash_folders[$term->term_taxonomy_id]);
3248 }
3249 }
3250 }
3251
3252 if (!empty($item['terms']) && is_array($item['terms'])) {
3253 foreach ($item['terms'] as $term) {
3254 wp_set_post_terms($item['post_id'], $term->term_id, $post_type, true);
3255 if (isset($trash_folders[$term->term_taxonomy_id])) {
3256 unset($trash_folders[$term->term_taxonomy_id]);
3257 }
3258 }
3259 }
3260 }
3261
3262 if (!empty($terms) && $initial_trash_folders != $trash_folders) {
3263 delete_transient("premio_folders_without_trash");
3264 set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS));
3265 }
3266 }//end if
3267 }//end if
3268
3269 echo wp_json_encode($response);
3270 die;
3271
3272 }//end wcp_undo_folder_changes()
3273
3274
3275 /**
3276 * Change post, page, attachment folder
3277 *
3278 * @since 1.0.0
3279 * @access public
3280 * @return $response
3281 */
3282 public function wcp_change_post_folder()
3283 {
3284 $response = [];
3285 $response['status'] = 0;
3286 $response['error'] = 0;
3287 $response['data'] = [];
3288 $response['message'] = "";
3289 $postData = filter_input_array(INPUT_POST);
3290 $errorCounter = 0;
3291 if (!isset($postData['post_id']) || empty($postData['post_id'])) {
3292 $errorCounter++;
3293 $response['message'] = esc_html__("Your request is not valid", 'folders');
3294 } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
3295 $errorCounter++;
3296 $response['message'] = esc_html__("Your request is not valid", 'folders');
3297 } else if (!isset($postData['type']) || empty($postData['type'])) {
3298 $errorCounter++;
3299 $response['message'] = esc_html__("Your request is not valid", 'folders');
3300 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3301 $response['message'] = esc_html__("Your request is not valid", 'folders');
3302 $errorCounter++;
3303 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
3304 $response['message'] = esc_html__("You have not permission to update folder", 'folders');
3305 $errorCounter++;
3306 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
3307 $response['message'] = esc_html__("You have not permission to update folder", 'folders');
3308 $errorCounter++;
3309 } else {
3310 $term_id = self::sanitize_options($postData['folder_id']);
3311 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3312 $response['message'] = esc_html__("Your request is not valid", 'folders');
3313 $errorCounter++;
3314 }
3315 }//end if
3316
3317 if ($errorCounter == 0) {
3318 $postID = self::sanitize_options($postData['post_id']);
3319 $folderID = self::sanitize_options($postData['folder_id']);
3320 $type = self::sanitize_options($postData['type']);
3321 $folder_post_type = self::get_custom_post_type($type);
3322 $status = 0;
3323 if (isset($postData['status'])) {
3324 $status = self::sanitize_options($postData['status']);
3325 }
3326
3327 $status = ($status == 1) ? true : false;
3328 $taxonomy = "";
3329 if (isset($postData['taxonomy'])) {
3330 $taxonomy = self::sanitize_options($postData['taxonomy']);
3331 }
3332
3333 $terms = get_the_terms($postID, $folder_post_type);
3334 if (!empty($terms)) {
3335 foreach ($terms as $term) {
3336 if (!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
3337 wp_remove_object_terms($postID, $term->term_id, $folder_post_type);
3338 }
3339 }
3340 }
3341
3342 wp_set_post_terms($postID, $folderID, $folder_post_type, true);
3343 $response['status'] = 1;
3344 }//end if
3345
3346 echo wp_json_encode($response);
3347 wp_die();
3348
3349 }//end wcp_change_post_folder()
3350
3351
3352 /**
3353 * Mark/Unmark folder
3354 *
3355 * @since 1.0.0
3356 * @access public
3357 * @return $response
3358 */
3359 public function wcp_mark_un_mark_folder()
3360 {
3361 $response = [];
3362 $response['status'] = 0;
3363 $response['error'] = 0;
3364 $response['data'] = [];
3365 $response['message'] = "";
3366 $postData = filter_input_array(INPUT_POST);
3367 $errorCounter = 0;
3368 if (!current_user_can("manage_categories")) {
3369 $response['message'] = esc_html__("You have not permission to update folder", 'folders');
3370 $errorCounter++;
3371 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
3372 $errorCounter++;
3373 $response['message'] = esc_html__("Your request is not valid", 'folders');
3374 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3375 $response['message'] = esc_html__("Your request is not valid", 'folders');
3376 $errorCounter++;
3377 } else {
3378 $term_id = self::sanitize_options($postData['term_id']);
3379 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3380 $response['message'] = esc_html__("Your request is not valid", 'folders');
3381 $errorCounter++;
3382 }
3383 }
3384
3385 if ($errorCounter == 0) {
3386 $term_id = self::sanitize_options($postData['term_id']);
3387 $folder_info = get_term_meta($term_id, "folder_info", true);
3388
3389 $status = intval(isset($folder_info['is_high'])?$folder_info['is_high']:0);
3390 $status = ($status) ? 0 : 1;
3391
3392 if ($folder_info) {
3393 $folder_info['is_high'] = $status;
3394 update_term_meta($term_id, "folder_info", $folder_info);
3395 } else {
3396 $folder_info = [];
3397 $folder_info['is_high'] = $status;
3398 add_term_meta($term_id, "folder_info", $folder_info);
3399 }
3400
3401 $response['marked'] = $status;
3402 $response['id'] = $term_id;
3403 $response['status'] = 1;
3404 }
3405
3406 echo wp_json_encode($response);
3407 wp_die();
3408
3409 }//end wcp_mark_un_mark_folder()
3410
3411
3412 /**
3413 * Make folder Sticky
3414 *
3415 * @since 1.0.0
3416 * @access public
3417 * @return $response
3418 */
3419 public function wcp_make_sticky_folder()
3420 {
3421 $response = [];
3422 $response['status'] = 0;
3423 $response['error'] = 0;
3424 $response['data'] = [];
3425 $response['message'] = "";
3426 $postData = filter_input_array(INPUT_POST);
3427 $errorCounter = 0;
3428 if (!current_user_can("manage_categories")) {
3429 $response['message'] = esc_html__("You have not permission to update folder", 'folders');
3430 $errorCounter++;
3431 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
3432 $errorCounter++;
3433 $response['message'] = esc_html__("Your request is not valid", 'folders');
3434 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3435 $response['message'] = esc_html__("Your request is not valid", 'folders');
3436 $errorCounter++;
3437 } else {
3438 $term_id = self::sanitize_options($postData['term_id']);
3439 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3440 $response['message'] = esc_html__("Your request is not valid", 'folders');
3441 $errorCounter++;
3442 }
3443 }
3444
3445 if ($errorCounter == 0) {
3446 $term_id = self::sanitize_options($postData['term_id']);
3447 $folder_info = get_term_meta($term_id, "folder_info", true);
3448
3449 $status = intval(isset($folder_info['is_sticky'])?$folder_info['is_sticky']:0);
3450 $status = ($status) ? 0 : 1;
3451
3452 if ($folder_info) {
3453 $folder_info['is_sticky'] = $status;
3454 update_term_meta($term_id, "folder_info", $folder_info);
3455 } else {
3456 $folder_info = [];
3457 $folder_info['is_sticky'] = $status;
3458 add_term_meta($term_id, "folder_info", $folder_info);
3459 }
3460
3461 $response['is_folder_sticky'] = $status;
3462 $response['id'] = $postData['term_id'];
3463 $response['status'] = 1;
3464 }
3465
3466 echo wp_json_encode($response);
3467 wp_die();
3468
3469 }//end wcp_make_sticky_folder()
3470
3471
3472 /**
3473 * Save folder order
3474 *
3475 * @since 1.0.0
3476 * @access public
3477 * @return $response
3478 */
3479 public function wcp_save_folder_order()
3480 {
3481 $response = [];
3482 $response['status'] = 0;
3483 $response['error'] = 0;
3484 $response['data'] = [];
3485 $response['message'] = "";
3486 $postData = filter_input_array(INPUT_POST);
3487 $errorCounter = 0;
3488 if (!current_user_can("manage_categories")) {
3489 $response['message'] = esc_html__("You have not permission to update folder order", 'folders');
3490 $errorCounter++;
3491 } else if (!isset($postData['term_ids']) || empty($postData['term_ids'])) {
3492 $errorCounter++;
3493 $response['message'] = esc_html__("Your request is not valid", 'folders');
3494 } else if (!isset($postData['type']) || empty($postData['type'])) {
3495 $errorCounter++;
3496 $response['message'] = esc_html__("Your request is not valid", 'folders');
3497 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3498 $response['message'] = esc_html__("Your request is not valid", 'folders');
3499 $errorCounter++;
3500 } else {
3501 $type = self::sanitize_options($postData['type']);
3502 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
3503 $response['message'] = esc_html__("Your request is not valid", 'folders');
3504 $errorCounter++;
3505 }
3506 }
3507
3508 if ($errorCounter == 0) {
3509 $termIds = self::sanitize_options(($postData['term_ids']));
3510 $type = self::sanitize_options($postData['type']);
3511 delete_option("wcp_custom_sort_" . $type);
3512 $termIds = trim($termIds, ",");
3513 $termArray = explode(",", $termIds);
3514 $order = 1;
3515 foreach ($termArray as $term) {
3516 if (!empty($term)) {
3517 update_term_meta($term, "wcp_custom_order", $order);
3518 $order++;
3519 }
3520 }
3521
3522 $term_id = self::sanitize_options($postData['term_id']);
3523 $parent_id = self::sanitize_options($postData['parent_id']);
3524 $type = self::sanitize_options($postData['type']);
3525 $folder_type = self::get_custom_post_type($type);
3526 wp_update_term(
3527 $term_id,
3528 $folder_type,
3529 ['parent' => $parent_id]
3530 );
3531
3532 if ($parent_id != "#" || !empty($parent_id)) {
3533 update_term_meta($parent_id, "is_active", 1);
3534 }
3535
3536 $response['status'] = 1;
3537 $folder_type = self::get_custom_post_type($type);
3538 // Free/Pro Class name change
3539 $response['options'] = WCP_Tree::get_option_data_for_select($folder_type);
3540 }//end if
3541
3542 echo wp_json_encode($response);
3543 wp_die();
3544
3545 }//end wcp_save_folder_order()
3546
3547
3548 /**
3549 * Make folder State open/closed
3550 *
3551 * @since 1.0.0
3552 * @access public
3553 * @return $response
3554 */
3555 public function save_wcp_folder_state()
3556 {
3557 $response = [];
3558 $response['status'] = 0;
3559 $response['error'] = 0;
3560 $response['data'] = [];
3561 $response['message'] = "";
3562 $postData = filter_input_array(INPUT_POST);
3563 $errorCounter = 0;
3564 if (!current_user_can("manage_categories")) {
3565 $response['message'] = esc_html__("You have not permission to update folder", 'folders');
3566 $errorCounter++;
3567 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
3568 $response['message'] = esc_html__("Your request is not valid", 'folders');
3569 $errorCounter++;
3570 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3571 $response['message'] = esc_html__("Unable to create folder, Your request is not valid", 'folders');
3572 $errorCounter++;
3573 } else {
3574 $term_id = self::sanitize_options($postData['term_id']);
3575 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3576 $response['message'] = esc_html__("Your request is not valid", 'folders');
3577 $errorCounter++;
3578 }
3579 }
3580
3581 if ($errorCounter == 0) {
3582 $response['status'] = 1;
3583 $term_id = self::sanitize_options($postData['term_id']);
3584 $is_active = isset($postData['is_active']) ? $postData['is_active'] : 0;
3585 $is_active = self::sanitize_options($is_active);
3586 $folder_info = get_term_meta($term_id, "folder_info", true);
3587
3588 if ($folder_info) {
3589 $folder_info['is_active'] = $is_active;
3590 update_term_meta($term_id, "folder_info", $folder_info);
3591 } else {
3592 $folder_info = [];
3593 $folder_info['is_active'] = $is_active;
3594 add_term_meta($term_id, "folder_info", $folder_info);
3595 }
3596 }
3597
3598 echo wp_json_encode($response);
3599 wp_die();
3600
3601 }//end save_wcp_folder_state()
3602
3603
3604 /**
3605 * Save parent folder information with order
3606 *
3607 * @since 1.0.0
3608 * @access public
3609 * @return $response
3610 */
3611 public function wcp_update_parent_information()
3612 {
3613 $response = [];
3614 $response['status'] = 0;
3615 $response['error'] = 0;
3616 $response['data'] = [];
3617 $response['message'] = "";
3618 $postData = filter_input_array(INPUT_POST);
3619 $errorCounter = 0;
3620 if (!current_user_can("manage_categories")) {
3621 $response['message'] = esc_html__("You have not permission to update folder", 'folders');
3622 $errorCounter++;
3623 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
3624 $response['message'] = esc_html__("Your request is not valid", 'folders');
3625 $errorCounter++;
3626 } else if (!isset($postData['type']) || empty($postData['type'])) {
3627 $response['message'] = esc_html__("Your request is not valid", 'folders');
3628 $errorCounter++;
3629 } else if (!isset($postData['parent_id'])) {
3630 $response['message'] = esc_html__("Your request is not valid", 'folders');
3631 $errorCounter++;
3632 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3633 $response['message'] = esc_html__("Your request is not valid", 'folders');
3634 $errorCounter++;
3635 } else {
3636 $term_id = self::sanitize_options($postData['term_id']);
3637 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3638 $response['message'] = esc_html__("Your request is not valid", 'folders');
3639 $errorCounter++;
3640 }
3641 }//end if
3642
3643 if ($errorCounter == 0) {
3644 $term_id = self::sanitize_options($postData['term_id']);
3645 $parent_id = self::sanitize_options($postData['parent_id']);
3646 $type = self::sanitize_options($postData['type']);
3647 $folder_type = self::get_custom_post_type($type);
3648 wp_update_term(
3649 $term_id,
3650 $folder_type,
3651 ['parent' => $parent_id]
3652 );
3653 update_term_meta($parent_id, "is_active", 1);
3654 $response['status'] = 1;
3655 }
3656
3657 echo wp_json_encode($response);
3658 wp_die();
3659
3660 }//end wcp_update_parent_information()
3661
3662
3663 /**
3664 * Save parent folder data
3665 *
3666 * @since 1.0.0
3667 * @access public
3668 * @return $response
3669 */
3670 public function wcp_save_parent_data()
3671 {
3672 $response = [];
3673 $response['status'] = 0;
3674 $response['error'] = 0;
3675 $response['data'] = [];
3676 $response['message'] = "";
3677 $postData = filter_input_array(INPUT_POST);
3678 $errorCounter = 0;
3679 if (!isset($postData['type']) || empty($postData['type'])) {
3680 $response['message'] = esc_html__("Your request is not valid", 'folders');
3681 $errorCounter++;
3682 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3683 $response['message'] = esc_html__("Your request is not valid", 'folders');
3684 $errorCounter++;
3685 } else if (!current_user_can("manage_categories")) {
3686 $response['message'] = esc_html__("Your request is not valid", 'folders');
3687 $errorCounter++;
3688 } else {
3689 $type = self::sanitize_options($postData['type']);
3690 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
3691 $response['message'] = esc_html__("Your request is not valid", 'folders');
3692 $errorCounter++;
3693 }
3694 }
3695
3696 if ($errorCounter == 0) {
3697 $type = self::sanitize_options($postData['type']);
3698 $optionName = $type."_parent_status";
3699 $response['status'] = 1;
3700 $is_active = isset($postData['is_active']) ? $postData['is_active'] : 0;
3701 $is_active = self::sanitize_options($is_active);
3702 if ($is_active == 1) {
3703 update_option($optionName, 1);
3704 } else {
3705 update_option($optionName, 0);
3706 }
3707 }
3708
3709 echo wp_json_encode($response);
3710 wp_die();
3711
3712 }//end wcp_save_parent_data()
3713
3714
3715 /**
3716 * Remove multiple folders
3717 *
3718 * @since 1.0.0
3719 * @access public
3720 * @return $response
3721 */
3722 public function remove_muliple_folder()
3723 {
3724 $response = [];
3725 $response['status'] = 0;
3726 $response['error'] = 0;
3727 $response['data'] = [];
3728 $response['message'] = "";
3729 $postData = filter_input_array(INPUT_POST);
3730 $errorCounter = 0;
3731 $error = "";
3732 if (!current_user_can("manage_categories")) {
3733 $error = esc_html__("You have not permission to remove folder", 'folders');
3734 $errorCounter++;
3735 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
3736 $error = esc_html__("Your request is not valid", 'folders');
3737 $errorCounter++;
3738 } else if (!isset($postData['type']) || empty($postData['type'])) {
3739 $error = esc_html__("Your request is not valid", 'folders');
3740 $errorCounter++;
3741 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3742 $response['message'] = esc_html__("Your request is not valid", 'folders');
3743 $errorCounter++;
3744 } else {
3745 $type = self::sanitize_options($postData['type']);
3746 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
3747 $error = esc_html__("Your request is not valid", 'folders');
3748 $errorCounter++;
3749 }
3750 }
3751
3752 if ($errorCounter == 0) {
3753 $term_id = self::sanitize_options($postData['term_id']);
3754 $type = self::sanitize_options($postData['type']);
3755 $response['term_ids'] = [];
3756 if (!empty($term_id)) {
3757 $term_id = trim($term_id, ",");
3758 $term_ids = explode(",", $term_id);
3759 if (is_array($term_ids) && count($term_ids) > 0) {
3760 foreach ($term_ids as $term) {
3761 self::remove_folder_child_items($term, $type);
3762 }
3763
3764 $response['term_ids'] = $term_ids;
3765 }
3766 }
3767
3768 $is_active = 1;
3769 $folders = -1;
3770 $response['status'] = 1;
3771 $response['folders'] = $folders;
3772 $response['is_key_active'] = $is_active;
3773 } else {
3774 $response['error'] = 1;
3775 $response['message'] = $error;
3776 }//end if
3777
3778 echo wp_json_encode($response);
3779 wp_die();
3780
3781 }//end remove_muliple_folder()
3782
3783
3784 /**
3785 * Remove folder
3786 *
3787 * @since 1.0.0
3788 * @access public
3789 * @return $response
3790 */
3791 public function wcp_remove_folder()
3792 {
3793 $response = [];
3794 $response['status'] = 0;
3795 $response['error'] = 0;
3796 $response['data'] = [];
3797 $response['message'] = "";
3798 $postData = filter_input_array(INPUT_POST);
3799 $errorCounter = 0;
3800 if (!current_user_can("manage_categories")) {
3801 $error = esc_html__("You have not permission to remove folder", 'folders');
3802 $errorCounter++;
3803 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
3804 $error = esc_html__("Your request is not valid", 'folders');
3805 $errorCounter++;
3806 } else if (!isset($postData['type']) || empty($postData['type'])) {
3807 $error = esc_html__("Your request is not valid", 'folders');
3808 $errorCounter++;
3809 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3810 $error = esc_html__("Unable to delete folder, Your request is not valid", 'folders');
3811 $errorCounter++;
3812 } else {
3813 $term_id = self::sanitize_options($postData['term_id']);
3814 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3815 $error = esc_html__("Unable to delete folder, Your request is not valid", 'folders');
3816 $errorCounter++;
3817 }
3818 }
3819
3820 if ($errorCounter == 0) {
3821 $term_id = self::sanitize_options($postData['term_id']);
3822 $type = self::sanitize_options($postData['type']);
3823 self::remove_folder_child_items($term_id, $type);
3824 $response['status'] = 1;
3825 $is_active = 1;
3826 $folders = -1;
3827 $response['folders'] = $folders;
3828 $response['term_id'] = $term_id;
3829 $response['is_key_active'] = $is_active;
3830 } else {
3831 $response['error'] = 1;
3832 $response['message'] = $error;
3833 }
3834
3835 echo wp_json_encode($response);
3836 wp_die();
3837
3838 }//end wcp_remove_folder()
3839
3840
3841 /**
3842 * Remove folders for page, post, attachment
3843 *
3844 * @since 1.0.0
3845 * @access public
3846 * @return $response
3847 */
3848 public function remove_folder_child_items($term_id, $post_type)
3849 {
3850 $folder_type = self::get_custom_post_type($post_type);
3851 $terms = get_terms(
3852 [
3853 'taxonomy' => $folder_type,
3854 'hide_empty' => false,
3855 'parent' => $term_id,
3856 ]
3857 );
3858
3859 if (!empty($terms)) {
3860 foreach ($terms as $term) {
3861 self::remove_folder_child_items($term->term_id, $post_type);
3862 }
3863
3864 wp_delete_term($term_id, $folder_type);
3865 } else {
3866 wp_delete_term($term_id, $folder_type);
3867 }
3868
3869 }//end remove_folder_child_items()
3870
3871
3872 /**
3873 * Update Folder
3874 *
3875 * @since 1.0.0
3876 * @access public
3877 * @return $response
3878 */
3879 public function wcp_update_folder()
3880 {
3881 $response = [];
3882 $response['status'] = 0;
3883 $response['error'] = 0;
3884 $response['data'] = [];
3885 $response['message'] = "";
3886 $postData = filter_input_array(INPUT_POST);
3887 $errorCounter = 0;
3888 if (!current_user_can("manage_categories")) {
3889 $error = esc_html__("You have not permission to update folder", 'folders');
3890 $errorCounter++;
3891 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
3892 $error = esc_html__("Unable to rename folder, Your request is not valid", 'folders');
3893 $errorCounter++;
3894 } else if (!isset($postData['name']) || empty($postData['name'])) {
3895 $error = esc_html__("Folder name can no be empty", 'folders');
3896 $errorCounter++;
3897 } else if (!isset($postData['type']) || empty($postData['type'])) {
3898 $error = esc_html__("Your request is not valid", 'folders');
3899 $errorCounter++;
3900 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
3901 $error = esc_html__("Unable to rename folder, Your request is not valid", 'folders');
3902 $errorCounter++;
3903 } else {
3904 $term_id = self::sanitize_options($postData['term_id']);
3905 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
3906 $error = esc_html__("Unable to rename folder, Your request is not valid", 'folders');
3907 $errorCounter++;
3908 }
3909 }//end if
3910
3911 if ($errorCounter == 0) {
3912 $type = self::sanitize_options($postData['type']);
3913 $folder_type = self::get_custom_post_type($type);
3914 $name = self::sanitize_options($postData['name']);
3915 $term_id = self::sanitize_options($postData['term_id']);
3916 $result = wp_update_term(
3917 $term_id,
3918 $folder_type,
3919 ['name' => $name]
3920 );
3921 if (!empty($result)) {
3922 $term_nonce = wp_create_nonce('wcp_folder_term_'.$result['term_id']);
3923 $response['id'] = $result['term_id'];
3924 $response['slug'] = $result['slug'];
3925 $response['status'] = 1;
3926 $response['term_title'] = $postData['name'];
3927 $response['nonce'] = $term_nonce;
3928 } else {
3929 $response['message'] = esc_html__("Unable to rename folder", 'folders');
3930 }
3931 } else {
3932 $response['error'] = 1;
3933 $response['message'] = $error;
3934 }//end if
3935
3936 echo wp_json_encode($response);
3937 wp_die();
3938
3939 }//end wcp_update_folder()
3940
3941
3942 /**
3943 * Create slug from string
3944 *
3945 * @since 1.0.0
3946 * @access public
3947 * @return $slug
3948 */
3949 public static function create_slug_from_string($str)
3950 {
3951 $a = [
3952 'À',
3953 'Á',
3954 'Â',
3955 'Ã',
3956 'Ä',
3957 '�
3958 ',
3959 'Æ',
3960 'Ç',
3961 'È',
3962 'É',
3963 'Ê',
3964 'Ë',
3965 'Ì',
3966 'Í',
3967 'Î',
3968 'Ï',
3969 'Ð',
3970 'Ñ',
3971 'Ò',
3972 'Ó',
3973 'Ô',
3974 'Õ',
3975 'Ö',
3976 'Ø',
3977 'Ù',
3978 'Ú',
3979 'Û',
3980 'Ü',
3981 'Ý',
3982 'ß',
3983 'à',
3984 'á',
3985 'â',
3986 'ã',
3987 'ä',
3988 'å',
3989 'æ',
3990 'ç',
3991 'è',
3992 'é',
3993 'ê',
3994 'ë',
3995 'ì',
3996 'í',
3997 'î',
3998 'ï',
3999 'ñ',
4000 'ò',
4001 'ó',
4002 'ô',
4003 'õ',
4004 'ö',
4005 'ø',
4006 'ù',
4007 'ú',
4008 'û',
4009 'ü',
4010 'ý',
4011 'ÿ',
4012 'A',
4013 'a',
4014 'A',
4015 'a',
4016 'A',
4017 'a',
4018 'C',
4019 'c',
4020 'C',
4021 'c',
4022 'C',
4023 'c',
4024 'C',
4025 'c',
4026 'D',
4027 'd',
4028 'Ð',
4029 'd',
4030 'E',
4031 'e',
4032 'E',
4033 'e',
4034 'E',
4035 'e',
4036 'E',
4037 'e',
4038 'E',
4039 'e',
4040 'G',
4041 'g',
4042 'G',
4043 'g',
4044 'G',
4045 'g',
4046 'G',
4047 'g',
4048 'H',
4049 'h',
4050 'H',
4051 'h',
4052 'I',
4053 'i',
4054 'I',
4055 'i',
4056 'I',
4057 'i',
4058 'I',
4059 'i',
4060 'I',
4061 'i',
4062 '?',
4063 '?',
4064 'J',
4065 'j',
4066 'K',
4067 'k',
4068 'L',
4069 'l',
4070 'L',
4071 'l',
4072 'L',
4073 'l',
4074 '?',
4075 '?',
4076 'L',
4077 'l',
4078 'N',
4079 'n',
4080 'N',
4081 'n',
4082 'N',
4083 'n',
4084 '?',
4085 'O',
4086 'o',
4087 'O',
4088 'o',
4089 'O',
4090 'o',
4091 'Œ',
4092 'œ',
4093 'R',
4094 'r',
4095 'R',
4096 'r',
4097 'R',
4098 'r',
4099 'S',
4100 's',
4101 'S',
4102 's',
4103 'S',
4104 's',
4105 'Š',
4106 'š',
4107 'T',
4108 't',
4109 'T',
4110 't',
4111 'T',
4112 't',
4113 'U',
4114 'u',
4115 'U',
4116 'u',
4117 'U',
4118 'u',
4119 'U',
4120 'u',
4121 'U',
4122 'u',
4123 'U',
4124 'u',
4125 'W',
4126 'w',
4127 'Y',
4128 'y',
4129 'Ÿ',
4130 'Z',
4131 'z',
4132 'Z',
4133 'z',
4134 'Ž',
4135 'ž',
4136 '?',
4137 'ƒ',
4138 'O',
4139 'o',
4140 'U',
4141 'u',
4142 'A',
4143 'a',
4144 'I',
4145 'i',
4146 'O',
4147 'o',
4148 'U',
4149 'u',
4150 'U',
4151 'u',
4152 'U',
4153 'u',
4154 'U',
4155 'u',
4156 'U',
4157 'u',
4158 '?',
4159 '?',
4160 '?',
4161 '?',
4162 '?',
4163 '?',
4164 ];
4165 $b = [
4166 'A',
4167 'A',
4168 'A',
4169 'A',
4170 'A',
4171 'A',
4172 'AE',
4173 'C',
4174 'E',
4175 'E',
4176 'E',
4177 'E',
4178 'I',
4179 'I',
4180 'I',
4181 'I',
4182 'D',
4183 'N',
4184 'O',
4185 'O',
4186 'O',
4187 'O',
4188 'O',
4189 'O',
4190 'U',
4191 'U',
4192 'U',
4193 'U',
4194 'Y',
4195 's',
4196 'a',
4197 'a',
4198 'a',
4199 'a',
4200 'a',
4201 'a',
4202 'ae',
4203 'c',
4204 'e',
4205 'e',
4206 'e',
4207 'e',
4208 'i',
4209 'i',
4210 'i',
4211 'i',
4212 'n',
4213 'o',
4214 'o',
4215 'o',
4216 'o',
4217 'o',
4218 'o',
4219 'u',
4220 'u',
4221 'u',
4222 'u',
4223 'y',
4224 'y',
4225 'A',
4226 'a',
4227 'A',
4228 'a',
4229 'A',
4230 'a',
4231 'C',
4232 'c',
4233 'C',
4234 'c',
4235 'C',
4236 'c',
4237 'C',
4238 'c',
4239 'D',
4240 'd',
4241 'D',
4242 'd',
4243 'E',
4244 'e',
4245 'E',
4246 'e',
4247 'E',
4248 'e',
4249 'E',
4250 'e',
4251 'E',
4252 'e',
4253 'G',
4254 'g',
4255 'G',
4256 'g',
4257 'G',
4258 'g',
4259 'G',
4260 'g',
4261 'H',
4262 'h',
4263 'H',
4264 'h',
4265 'I',
4266 'i',
4267 'I',
4268 'i',
4269 'I',
4270 'i',
4271 'I',
4272 'i',
4273 'I',
4274 'i',
4275 'IJ',
4276 'ij',
4277 'J',
4278 'j',
4279 'K',
4280 'k',
4281 'L',
4282 'l',
4283 'L',
4284 'l',
4285 'L',
4286 'l',
4287 'L',
4288 'l',
4289 'l',
4290 'l',
4291 'N',
4292 'n',
4293 'N',
4294 'n',
4295 'N',
4296 'n',
4297 'n',
4298 'O',
4299 'o',
4300 'O',
4301 'o',
4302 'O',
4303 'o',
4304 'OE',
4305 'oe',
4306 'R',
4307 'r',
4308 'R',
4309 'r',
4310 'R',
4311 'r',
4312 'S',
4313 's',
4314 'S',
4315 's',
4316 'S',
4317 's',
4318 'S',
4319 's',
4320 'T',
4321 't',
4322 'T',
4323 't',
4324 'T',
4325 't',
4326 'U',
4327 'u',
4328 'U',
4329 'u',
4330 'U',
4331 'u',
4332 'U',
4333 'u',
4334 'U',
4335 'u',
4336 'U',
4337 'u',
4338 'W',
4339 'w',
4340 'Y',
4341 'y',
4342 'Y',
4343 'Z',
4344 'z',
4345 'Z',
4346 'z',
4347 'Z',
4348 'z',
4349 's',
4350 'f',
4351 'O',
4352 'o',
4353 'U',
4354 'u',
4355 'A',
4356 'a',
4357 'I',
4358 'i',
4359 'O',
4360 'o',
4361 'U',
4362 'u',
4363 'U',
4364 'u',
4365 'U',
4366 'u',
4367 'U',
4368 'u',
4369 'U',
4370 'u',
4371 'A',
4372 'a',
4373 'AE',
4374 'ae',
4375 'O',
4376 'o',
4377 ];
4378 return strtolower(preg_replace(['/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'], ['', '-', ''], str_replace($a, $b, $str)));
4379
4380 }//end create_slug_from_string()
4381
4382
4383 /**
4384 * Sanitize input options
4385 *
4386 * @since 1.0.0
4387 * @access public
4388 * @return $value
4389 */
4390 public static function sanitize_options($value, $type="")
4391 {
4392 $value = stripslashes($value);
4393 if ($type == "int") {
4394 $value = filter_var($value, FILTER_SANITIZE_NUMBER_INT);
4395 } else if ($type == "email") {
4396 $value = filter_var($value, FILTER_SANITIZE_EMAIL);
4397 } else {
4398 $value = sanitize_text_field($value);
4399 }
4400
4401 return $value;
4402
4403 }//end sanitize_options()
4404
4405
4406 /**
4407 * Add new folder
4408 *
4409 * @since 1.0.0
4410 * @access public
4411 * @return $response
4412 */
4413 public function wcp_add_new_folder()
4414 {
4415 $response = [];
4416 $response['status'] = 0;
4417 $response['error'] = 0;
4418 $response['login'] = 1;
4419 $response['data'] = [];
4420 $response['message'] = "";
4421 $response['message2'] = "";
4422 $postData = filter_input_array(INPUT_POST);
4423 $errorCounter = 0;
4424 $error = esc_html__("Your request is not valid", 'folders');
4425 if (!current_user_can("manage_categories")) {
4426 $error = esc_html__("You have not permission to add folder", 'folders');
4427 $errorCounter++;
4428 } else if (!isset($postData['name']) || empty($postData['name'])) {
4429 $error = esc_html__("Folder name can no be empty", 'folders');
4430 $errorCounter++;
4431 } else if (!isset($postData['type']) || empty($postData['type'])) {
4432 $error = esc_html__("Your request is not valid", 'folders');
4433 $errorCounter++;
4434 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
4435 $response['login'] = 0;
4436 $error = esc_html__("Unable to create folder, Your request is not valid", 'folders');
4437 $errorCounter++;
4438 } else {
4439 $type = self::sanitize_options($postData['type']);
4440 if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
4441 $response['login'] = 0;
4442 $error = esc_html__("Unable to create folder, Your request is not valid", 'folders');
4443 $errorCounter++;
4444 }
4445 }//end if
4446
4447 if ($errorCounter == 0) {
4448 $parent = isset($postData['parent_id']) && !empty($postData['parent_id']) ? $postData['parent_id'] : 0;
4449 $parent = self::sanitize_options($parent);
4450 $type = self::sanitize_options($postData['type']);
4451 $folder_type = self::get_custom_post_type($type);
4452 $term_name = self::sanitize_options($postData['name']);
4453 $term = term_exists($term_name, $folder_type, $parent);
4454 $user_id = get_current_user_id();
4455 if (!empty($term) && isset($term['term_id']) && !empty($term['term_id'])) {
4456 $term_user = get_term_meta($term['term_id'], "created_by", true);
4457 if ($term_user == $user_id) {
4458 $response['error'] = 1;
4459 $response['message'] = esc_html__("Folder name already exists", 'folders');
4460 echo wp_json_encode($response);
4461 wp_die();
4462 }
4463 }
4464
4465 $folders = $postData['name'];
4466 $folders = explode(",", $folders);
4467 $foldersArray = [];
4468 //$order = isset($postData['order']) ? $postData['order'] : 0;
4469 //$order = self::sanitize_options($order);
4470
4471 $is_active = 1;
4472 $created_folders = 0;
4473
4474 foreach ($folders as $key => $folder) {
4475 $term = term_exists($folder, $folder_type, $parent);
4476 if (!empty($term) && isset($term['term_id']) && !empty($term['term_id'])) {
4477 $term_user = get_term_meta($term['term_id'], "created_by", true);
4478 if ($term_user == $user_id) {
4479 continue;
4480 }
4481 }
4482
4483 $folder = trim($folder);
4484 $slug = self::create_slug_from_string($folder)."-".time()."-".$user_id;
4485
4486 $result = wp_insert_term(
4487 urldecode($folder),
4488 // the term
4489 $folder_type,
4490 // the taxonomy
4491 [
4492 'parent' => $parent,
4493 'slug' => $slug,
4494 ]
4495 );
4496
4497 if (!empty($result)) {
4498 $created_folders++;
4499 $response['id'] = $result['term_id'];
4500 $response['status'] = 1;
4501 $term = get_term($result['term_id'], $folder_type);
4502 $order = $key+1;
4503 $term_nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
4504
4505 $folder_item = [];
4506 $folder_item['parent_id'] = $parent;
4507 $folder_item['slug'] = $term->slug;
4508 $folder_item['nonce'] = $term_nonce;
4509 $folder_item['term_id'] = $result['term_id'];
4510 $folder_item['title'] = $folder;
4511 $folder_item['parent_id'] = empty($postData['parent_id']) ? "0" : $postData['parent_id'];
4512 $folder_item['is_sticky'] = 0;
4513 $folder_item['is_high'] = 0;
4514 $folder_item['is_locked'] = 0;
4515 $folder_item['folder_count'] = 0;
4516 $folder_item['has_color'] ='';
4517
4518 add_term_meta($result['term_id'], "created_by", $user_id);
4519
4520 update_term_meta($result['term_id'], "wcp_custom_order", $order);
4521 if ($parent != 0) {
4522 update_term_meta($parent, "is_active", 1);
4523 }
4524
4525 if (isset($postData['is_duplicate']) && $postData['is_duplicate'] == true) {
4526 if (isset($postData['duplicate_from']) && !empty($postData['duplicate_from'])) {
4527 $term_id = $postData['duplicate_from'];
4528
4529 $term_data = get_term($term_id, $folder_type);
4530 if (!empty($term_data)) {
4531
4532 $folder_info = get_term_meta($term_id, "folder_info", true);
4533 $folder_info = shortcode_atts([
4534 'is_sticky' => 0,
4535 'is_high' => 0,
4536 'is_locked' => 0,
4537 'is_active' => 0,
4538 'has_color' => ''
4539 ], $folder_info);
4540
4541 $folder_item['is_active'] = intval($folder_info['is_active']);
4542 $folder_item['is_high'] = intval($folder_info['is_high']);
4543 $folder_item['is_locked'] = intval($folder_info['is_locked']);
4544 $folder_item['is_sticky'] = intval($folder_info['is_sticky']);
4545 $folder_item['has_color'] = $folder_info['has_color'];
4546
4547 add_term_meta($term->term_id, "folder_info", $folder_info);
4548
4549 $postArray = get_posts(
4550 [
4551 'posts_per_page' => -1,
4552 'post_type' => $type,
4553 'tax_query' => [
4554 [
4555 'taxonomy' => $folder_type,
4556 'field' => 'term_id',
4557 'terms' => $term_id,
4558 ],
4559 ],
4560 ]
4561 );
4562 if (!empty($postArray)) {
4563 foreach ($postArray as $p) {
4564 wp_set_post_terms($p->ID, $term->term_id, $folder_type, true);
4565 }
4566
4567 $folder_item['folder_count'] = count($postArray);
4568 }
4569 }//end if
4570 }//end if
4571 }//end if
4572
4573 $foldersArray[] = $folder_item;
4574 }//end if
4575
4576 $folders = $postData['folders'];
4577 if(is_array($folders) && count($folders) > 0) {
4578 foreach($folders as $folder) {
4579 $order++;
4580 update_term_meta($folder, "wcp_custom_order", $order);
4581 }
4582 }
4583
4584 if (!empty($foldersArray)) {
4585 $response['is_key_active'] = $is_active;
4586 $response['folders'] = $created_folders;
4587 $response['parent_id'] = empty($parent) ? "#" : $parent;
4588
4589 $response['status'] = 1;
4590 $response['data'] = $foldersArray;
4591 }
4592 }//end foreach
4593 } else {
4594 $response['error'] = 1;
4595 $response['message'] = $error;
4596 }//end if
4597
4598 echo wp_json_encode($response);
4599 wp_die();
4600
4601 }//end wcp_add_new_folder()
4602
4603
4604 /**
4605 * Check is folder active for post, page, attachment
4606 *
4607 * @since 1.0.0
4608 * @access public
4609 * @return $post_type
4610 */
4611 public function is_for_this_post_type($post_type)
4612 {
4613 $post_types = get_option('folders_settings');
4614 $post_types = is_array($post_types) ? $post_types : [];
4615 return in_array($post_type, $post_types);
4616
4617 }//end is_for_this_post_type()
4618
4619
4620 /**
4621 * Check is folder active for current screen
4622 *
4623 * @since 1.0.0
4624 * @access public
4625 * @return $status
4626 */
4627 public function is_active_for_screen()
4628 {
4629 global $typenow, $current_screen;
4630
4631 $postData = filter_input_array(INPUT_POST);
4632
4633 global $current_screen;
4634
4635 if (self::is_for_this_post_type($typenow) && ('edit' == $current_screen->base || 'upload' == $current_screen->base)) {
4636 return true;
4637 }
4638
4639 $post_types = get_option('folders_settings');
4640 $post_types = is_array($post_types) ? $post_types : [];
4641
4642 if (empty($typenow) && (isset($current_screen->base) && 'upload' == $current_screen->base)) {
4643 $typenow = "attachment";
4644 if (self::is_for_this_post_type($typenow)) {
4645 return true;
4646 }
4647 }
4648
4649 return false;
4650
4651 }//end is_active_for_screen()
4652
4653
4654 /**
4655 * Check is post update screen
4656 *
4657 * @since 1.0.0
4658 * @access public
4659 * @return $status
4660 */
4661 public function is_add_update_screen()
4662 {
4663 global $current_screen;
4664 $current_type = $current_screen->base;
4665 $action = $current_screen->action;
4666 $post_types = get_option('folders_settings');
4667 $post_types = is_array($post_types) ? $post_types : [];
4668 global $typenow;
4669 if (in_array($current_type, $post_types) && in_array($action, ["add", ""])) {
4670 $license_data = self::get_license_key_data();
4671
4672 $is_active = 1;
4673 $folders = -1;
4674 $response['folders'] = $folders;
4675 $response['is_key_active'] = $is_active;
4676 }
4677
4678 }//end is_add_update_screen()
4679
4680
4681 /**
4682 * Get folder type for page, post, attachment
4683 *
4684 * @since 1.0.0
4685 * @access public
4686 * @return $status
4687 */
4688 public static function get_custom_post_type($post_type)
4689 {
4690 if ($post_type == "post") {
4691 return "post_folder";
4692 } else if ($post_type == "page") {
4693 return "folder";
4694 } else if ($post_type == "attachment") {
4695 return "media_folder";
4696 }
4697
4698 return $post_type.'_folder';
4699
4700 }//end get_custom_post_type()
4701
4702 /**
4703 * Combine all folders setting to one meta
4704 *
4705 * @since 1.0.0
4706 * @access public
4707 */
4708 public function migrate_folders_settings() {
4709 global $wpdb;
4710 $status = get_option('folders_term_meta_migrated');
4711
4712 /* Checking for Thrive data */
4713 if($status == "yes") {
4714 $status = get_option('folders_checked_for_thrive_conflict');
4715 if($status != "yes") {
4716 add_option("folders_checked_for_thrive_conflict", "yes");
4717 $tbl_termmeta = $wpdb->prefix . 'termmeta';
4718
4719 $query = "SELECT meta_id, term_id, meta_key, meta_value
4720 FROM {$tbl_termmeta}
4721 WHERE meta_key = 'is_locked'";
4722
4723 $results = $wpdb->get_results($query);
4724
4725 if (!empty($results)) {
4726 foreach ($results as $result) {
4727 $folder_data = get_term_meta($result->term_id, 'folder_info', true);
4728 if(isset($folder_data['is_active'])) {
4729 add_term_meta($result->term_id, 'is_active', $folder_data['is_active'], true);
4730 }
4731 }
4732 }
4733 }
4734 }
4735 if($status != 'yes') {
4736 add_option("folders_term_meta_migrated", "yes");
4737 add_option("folders_checked_for_thrive_conflict", "yes");
4738 $tbl_termmeta = $wpdb->prefix . 'termmeta';
4739
4740 $query = "SELECT meta_id, term_id, meta_key, meta_value
4741 FROM {$tbl_termmeta}
4742 WHERE meta_key = 'is_locked'";
4743
4744 $results = $wpdb->get_results($query);
4745
4746 $folder_setting = [];
4747 if (!empty($results)) {
4748 foreach ($results as $result) {
4749 $folder_setting[$result->term_id]['is_locked'] = $result->meta_value;
4750 delete_term_meta($result->term_id, 'is_locked');
4751 }
4752 }
4753 $query = "SELECT meta_id, term_id, meta_key, meta_value
4754 FROM {$tbl_termmeta}
4755 WHERE meta_key = 'is_folder_sticky'";
4756
4757 $results = $wpdb->get_results($query);
4758
4759 if (!empty($results)) {
4760 foreach ($results as $result) {
4761 $folder_setting[$result->term_id]['is_sticky'] = $result->meta_value;
4762 delete_term_meta($result->term_id, 'is_folder_sticky');
4763 }
4764 }
4765 $query = "SELECT meta_id, term_id, meta_key, meta_value
4766 FROM {$tbl_termmeta}
4767 WHERE meta_key = 'is_highlighted'";
4768
4769 $results = $wpdb->get_results($query);
4770
4771 if (!empty($results)) {
4772 foreach ($results as $result) {
4773 $folder_setting[$result->term_id]['is_high'] = $result->meta_value;
4774 delete_term_meta($result->term_id, 'is_highlighted');
4775 }
4776 }
4777 $query = "SELECT meta_id, term_id, meta_key, meta_value
4778 FROM {$tbl_termmeta}
4779 WHERE meta_key = 'is_active'";
4780
4781 $results = $wpdb->get_results($query);
4782
4783 if (!empty($results)) {
4784 foreach ($results as $result) {
4785 $folder_setting[$result->term_id]['is_active'] = $result->meta_value;
4786 //delete_term_meta($result->term_id, 'is_active');
4787 }
4788 }
4789
4790 if (!empty($folder_setting)) {
4791 foreach ($folder_setting as $term_id => $setting) {
4792 update_term_meta($term_id, 'folder_info', $setting);
4793 }
4794 }
4795 }
4796 }
4797
4798 /**
4799 * Add folders data to footer
4800 *
4801 * @since 1.0.0
4802 * @access public
4803 * @return $html
4804 */
4805 public function admin_footer()
4806 {
4807 if (self::is_active_for_screen()) {
4808 $this->migrate_folders_settings();
4809 global $typenow;
4810
4811 self::set_default_values_if_not_exists();
4812
4813 $ttpsts = self::get_ttlpst($typenow);
4814
4815 $ttemp = self::get_tempt_posts($typenow);
4816
4817 $folder_type = self::get_custom_post_type($typenow);
4818 // Do not change: Free/Pro Class name change
4819 $tree_data = WCP_Tree::get_full_tree_data($folder_type);
4820 $terms_data = $tree_data['string'];
4821 $sticky_string = $tree_data['sticky_string'];
4822 $terms_html = WCP_Tree::get_option_data_for_select($folder_type);
4823 $form_html = WCP_Forms::get_form_html($terms_html, $typenow);
4824 include_once dirname(dirname(__FILE__)).WCP_DS."/templates".WCP_DS."admin".WCP_DS."admin-content.php";
4825 }
4826
4827 global $pagenow;
4828 if ('plugins.php' !== $pagenow) {
4829 } else {
4830 if (current_user_can('manage_options')) {
4831 include_once dirname(dirname(__FILE__)).WCP_DS."/templates".WCP_DS."admin".WCP_DS."folder-deactivate-form.php";
4832 }
4833 }
4834
4835 }//end admin_footer()
4836
4837
4838 /**
4839 * Get total posts
4840 *
4841 * @since 1.0.0
4842 * @access public
4843 * @return $item_count
4844 */
4845 public function get_ttlpst($post_type="")
4846 {
4847 global $typenow;
4848 if (empty($post_type)) {
4849 $post_type = $typenow;
4850 }
4851 $item_count = null;
4852 if(has_filter("premio_folder_all_categorized_items")) {
4853 $item_count = apply_filters("premio_folder_all_categorized_items", $post_type);
4854 }
4855 if($item_count === null) {
4856 if ($post_type == "attachment") {
4857 global $wpdb;
4858
4859 $select = "SELECT COUNT(ID) FROM ".$wpdb->posts." as P ";
4860
4861 $where = ["post_type = 'attachment' "];
4862 $where[] = "(post_status = 'inherit' OR post_status = 'private')";
4863
4864 $join = apply_filters( 'folders_count_join_query', "" );
4865 $where = apply_filters( 'folders_count_where_query', $where );
4866
4867 $query = $select . $join . " WHERE ".implode( ' AND ', $where );
4868
4869 $item_count = $wpdb->get_var($query);
4870 } else {
4871 $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 + wp_count_posts($post_type)->pending;
4872 }
4873 }
4874 return $item_count;
4875 }//end get_ttlpst()
4876
4877 /**
4878 * Condition for Media hooks for Elementor, BuddyPress
4879 *
4880 * @since 2.9
4881 * @access public
4882 */
4883 public function folders_count_where_query($where) {
4884 global $wpdb;
4885 if(class_exists( 'Better_Messages' )) {
4886 $where[] = " BMPM.post_id IS NULL ";
4887 }
4888 if(class_exists( 'buddypress' )) {
4889 $where[] = " bb_mt1.post_id IS NULL ";
4890 $where[] = " bb_mt2.post_id IS NULL ";
4891 $where[] = " bb_mt3.post_id IS NULL ";
4892 }
4893 if ( function_exists( '_is_elementor_installed' ) ) {
4894 $where[] = " ELPM.post_id IS NULL ";
4895 }
4896 if(class_exists("Web_Stories_Compatibility")) {
4897 $query = "SELECT t.term_id
4898 FROM ".$wpdb->terms." AS t
4899 INNER JOIN ".$wpdb->term_taxonomy." AS tt
4900 ON t.term_id = tt.term_id
4901 WHERE tt.taxonomy IN ('web_story_media_source')
4902 AND t.slug IN ('poster-generation', 'source-video', 'source-image', 'page-template')";
4903 $results = $wpdb->get_results($query);
4904 if(!empty($results)) {
4905 $termsIds = [];
4906 foreach($results as $result) {
4907 if(isset($result->term_id) && !empty($result->term_id)) {
4908 $termsIds[] = $result->term_id;
4909 }
4910 }
4911
4912 if(!empty($termsIds)) {
4913 $termsIds = implode(",", $termsIds);
4914 $where[] = "(P.ID NOT IN (SELECT object_id
4915 FROM ".$wpdb->term_relationships."
4916 WHERE term_taxonomy_id IN ($termsIds)))";
4917 }
4918 }
4919 }
4920 if(class_exists("youzify_media")) {
4921 $term = get_term_by( 'slug', 'youzify_media', 'category' );
4922 if(isset($term->term_id)) {
4923 $where[] = "( P.ID NOT IN (
4924 SELECT object_id
4925 FROM ".$wpdb->term_relationships."
4926 WHERE term_taxonomy_id IN (".$term->term_id.") ) )";
4927 }
4928 }
4929
4930 /* W3 Cache */
4931 if(defined("W3TC")) {
4932 $where[] = "( WTCPM.post_id IS NULL )";
4933 }
4934
4935 /* Jetbrain Video */
4936 if(defined("JETPACK_VIDEOPRESS_NAME")) {
4937 $where[] = " JBV.post_id IS NULL ";
4938 }
4939 return $where;
4940 }
4941
4942 /**
4943 * Folders Query for Media
4944 *
4945 * @since 2.9
4946 * @access public
4947 */
4948 public function folders_count_join_query($join) {
4949 global $wpdb;
4950 if(class_exists( 'Better_Messages' )) {
4951 $join .= " LEFT JOIN " . $wpdb->postmeta . " AS BMPM
4952 ON ( P.ID = BMPM.post_id
4953 AND BMPM.meta_key = 'bp-better-messages-attachment') ";
4954 }
4955 if(class_exists( 'buddypress' )) {
4956 $join .= " LEFT JOIN ".$wpdb->postmeta." AS bb_mt1
4957 ON (P.ID = bb_mt1.post_id
4958 AND bb_mt1.meta_key = 'bp_media_upload' ) ";
4959
4960 $join .= " LEFT JOIN ".$wpdb->postmeta." AS bb_mt2
4961 ON (P.ID = bb_mt2.post_id
4962 AND bb_mt2.meta_key = 'bp_document_upload' ) ";
4963
4964 $join .= " LEFT JOIN ".$wpdb->postmeta." AS bb_mt3
4965 ON (P.ID = bb_mt3.post_id
4966 AND bb_mt3.meta_key = 'bp_video_upload' ) ";
4967
4968 }
4969 if ( function_exists( '_is_elementor_installed' ) ) {
4970 $join .= " LEFT JOIN ".$wpdb->postmeta." AS ELPM
4971 ON ( P.ID = ELPM.post_id
4972 AND ELPM.meta_key = '_elementor_is_screenshot') ";
4973 }
4974 if(defined("W3TC")) {
4975 $join .= "LEFT JOIN ".$wpdb->postmeta." AS WTCPM
4976 ON ( P.ID = WTCPM.post_id
4977 AND WTCPM.meta_key = 'w3tc_imageservice_file' )";
4978 }
4979 if(defined("JETPACK_VIDEOPRESS_NAME")) {
4980 $join .= " LEFT JOIN ".$wpdb->postmeta." AS JBV
4981 ON ( P.ID = JBV.post_id
4982 AND JBV.meta_key = 'videopress_poster_image') ";
4983 }
4984 return $join;
4985 }
4986
4987 /**
4988 * Autoload folders librarires
4989 *
4990 * @since 1.0.0
4991 * @access public
4992 * @return $files
4993 */
4994 public function autoload()
4995 {
4996 $files = [
4997 'WCP_Tree_View' => WCP_DS."includes".WCP_DS."tree.class.php",
4998 'WCP_Form_View' => WCP_DS."includes".WCP_DS."form.class.php",
4999 'WCP_Folder_WPML' => WCP_DS."includes".WCP_DS."class-wpml.php",
5000 'WCP_Folder_PolyLang' => WCP_DS."includes".WCP_DS."class-polylang.php",
5001 'Folders_Notifications' => WCP_DS."includes".WCP_DS."notifications.class.php",
5002 'Folders_Import_Export' => WCP_DS."includes".WCP_DS."import.export.class.php",
5003 ];
5004
5005 foreach ($files as $file) {
5006 if (file_exists(dirname(dirname(__FILE__)).$file)) {
5007 include_once dirname(dirname(__FILE__)).$file;
5008 }
5009 }
5010
5011 }//end autoload()
5012
5013
5014 /**
5015 * Create folder taxonomies
5016 *
5017 * @since 1.0.0
5018 * @access public
5019 * @return $taxonomies
5020 */
5021 public function create_folder_terms()
5022 {
5023 $options = get_option('folders_settings');
5024 $options = is_array($options) ? $options : [];
5025 $old_plugin_status = 0;
5026 $posts = [];
5027 if (!empty($options)) {
5028 foreach ($options as $option) {
5029 if (!(strpos($option, 'folder4') === false) && $old_plugin_status == 0) {
5030 $old_plugin_status = 1;
5031 }
5032
5033 if (in_array($option, ["page", "post", "attachment"])) {
5034 $posts[] = str_replace("folder4", "", $option);
5035 } else {
5036 $posts[] = $option;
5037 }
5038 }
5039
5040 if (!empty($posts)) {
5041 update_option('folders_settings', $posts);
5042 }
5043 }
5044
5045 if ($old_plugin_status == 1) {
5046 update_option("folders_show_in_menu", "on");
5047 $old_plugin_var = get_option("folder_old_plugin_status");
5048 if (empty($old_plugin_var) || $old_plugin_var == null) {
5049 update_option("folder_old_plugin_status", "1");
5050 }
5051 }
5052
5053 $posts = get_option('folders_settings');
5054 if (!empty($posts)) {
5055 foreach ($posts as $post_type) {
5056 $labels = [
5057 'name' => esc_html__('Folders', 'folders'),
5058 'singular_name' => esc_html__('Folder', 'folders'),
5059 'all_items' => esc_html__('All Folders', 'folders'),
5060 'edit_item' => esc_html__('Edit Folder', 'folders'),
5061 'update_item' => esc_html__('Update Folder', 'folders'),
5062 'add_new_item' => esc_html__('Add New Folder', 'folders'),
5063 'new_item_name' => esc_html__('Add folder name', 'folders'),
5064 'menu_name' => esc_html__('Folders', 'folders'),
5065 'search_items' => esc_html__('Search Folders', 'folders'),
5066 'parent_item' => esc_html__('Parent Folder', 'folders'),
5067 ];
5068
5069 $args = [
5070 'label' => esc_html__('Folder', 'folders'),
5071 'labels' => $labels,
5072 'show_tagcloud' => false,
5073 'hierarchical' => true,
5074 'public' => false,
5075 'show_ui' => true,
5076 'show_in_menu' => false,
5077 'show_in_rest' => true,
5078 'show_admin_column' => true,
5079 'update_count_callback' => '_update_post_term_count',
5080 // 'update_count_callback' => '_update_generic_term_count',
5081 'query_var' => true,
5082 'rewrite' => false,
5083 'capabilities' => [
5084 'manage_terms' => 'manage_categories',
5085 'edit_terms' => 'manage_categories',
5086 'delete_terms' => 'manage_categories',
5087 'assign_terms' => 'manage_categories',
5088 ],
5089 ];
5090
5091 $folder_post_type = self::get_custom_post_type($post_type);
5092
5093 register_taxonomy(
5094 $folder_post_type,
5095 $post_type,
5096 $args
5097 );
5098 }//end foreach
5099 }//end if
5100
5101 $postData = filter_input_array(INPUT_POST);
5102
5103 if (current_user_can("manage_categories") && isset($postData['folder_nonce'])) {
5104 if (wp_verify_nonce($postData['folder_nonce'], "folder_settings")) {
5105 if (isset($postData['folders_settings1'])) {
5106 $posts = [];
5107 if (isset($postData['folders_settings']) && is_array($postData['folders_settings'])) {
5108 foreach ($postData['folders_settings'] as $key => $val) {
5109 $posts[] = $val;
5110 }
5111 }
5112
5113 update_option("folders_settings", $posts);
5114 }
5115
5116 $postData = filter_input_array(INPUT_POST);
5117
5118 if (isset($postData['folders_settings1'])) {
5119 $posts = [];
5120 if (isset($postData['default_folders']) && is_array($postData['default_folders'])) {
5121 foreach ($postData['default_folders'] as $key => $val) {
5122 $posts[$key] = $val;
5123 }
5124 }
5125
5126 update_option("default_folders", $posts);
5127 }
5128
5129 if (isset($postData['customize_folders'])) {
5130 $posts = [];
5131 if (isset($postData['customize_folders']) && is_array($postData['customize_folders'])) {
5132 foreach ($postData['customize_folders'] as $key => $val) {
5133 $posts[$key] = $val;
5134 }
5135 }
5136
5137 update_option("customize_folders", $posts);
5138 }
5139
5140 $setting_page = $this->getFolderSettingsURL();
5141 if (!empty($setting_page)) {
5142 $page = filter_input(INPUT_POST, 'tab_page');
5143 $type = filter_input(INPUT_GET, 'setting_page');
5144 $type = empty($type) ? "" : "&setting_page=".esc_attr($type);
5145 $setting_page = $setting_page.$type;
5146 if (!empty($page)) {
5147 $setting_page .= "&setting_page=".esc_attr($page);
5148 }
5149
5150 wp_redirect($setting_page."&note=1");
5151 exit;
5152 } else {
5153 $folder_page = filter_input(INPUT_POST, 'folder_page');
5154 if (!empty($folder_page)) {
5155 wp_redirect($folder_page);
5156 exit;
5157 }
5158 }
5159 }//end if
5160 }//end if
5161
5162 // $old_version = get_option("folder_old_plugin_status");
5163 // if($old_version !== false && $old_version == 1) {
5164 // $tlfs = get_option("folder_old_plugin_folder_status");
5165 // if($tlfs === false) {
5166 // $total = self::ttl_fldrs();
5167 // if($total <= 10) {
5168 // $total = 10;
5169 // };
5170 // update_option("folder_old_plugin_folder_status", $total);
5171 // self::$folders = $total;
5172 // } else {
5173 // self::$folders = $tlfs;
5174 // }
5175 // }
5176 //
5177 // $tlfs = get_option("folder_old_plugin_folder_status");
5178 // if($tlfs === false) {
5179 // self::$folders = 10;
5180 // } else {
5181 // self::$folders = $tlfs;
5182 // }
5183
5184 }//end create_folder_terms()
5185
5186
5187 /**
5188 * Search for data from list
5189 *
5190 * @since 1.0.0
5191 * @access public
5192 * @return $key
5193 */
5194 function searchForId($id, $menu)
5195 {
5196 if ($menu) {
5197 foreach ($menu as $key => $val) {
5198 if (array_key_exists(2, $val)) {
5199 $stripVal = explode('=', $val[2]);
5200 }
5201
5202 if (array_key_exists(1, $stripVal)) {
5203 $stripVal = $stripVal[1];
5204 }
5205
5206 if ($stripVal === $id) {
5207 return $key;
5208 }
5209 }
5210 }
5211
5212 }//end searchForId()
5213
5214
5215 /**
5216 * Create setting menu for folders
5217 *
5218 * @since 1.0.0
5219 * @access public
5220 */
5221 function create_menu_for_folders()
5222 {
5223 global $menu;
5224 self::check_and_set_post_type();
5225
5226 $folder_types = get_option("folders_settings");
5227 if (empty($folder_types)) {
5228 return;
5229 }
5230
5231 foreach ($folder_types as $type) {
5232 $itemKey = self::searchForId($type, $menu);
5233 switch (true) {
5234 case ($type == 'attachment'):
5235 $itemKey = 10;
5236 $edit = 'upload.php';
5237 break;
5238 case ($type === 'post'):
5239 $edit = 'edit.php';
5240 $itemKey = 5;
5241 break;
5242 default:
5243 $edit = 'edit.php';
5244 break;
5245 }
5246
5247 $folder = $type == 'attachment' ? 'media' : $type;
5248 $upper = $type == 'attachment' ? 'Media' : ucwords(str_replace(['-', '_'], ' ', $type));
5249 if ($type == 'page') {
5250 $tax_slug = 'folder';
5251 } else {
5252 $tax_slug = $folder.'_folder';
5253 }
5254
5255 $hide_empty = true;
5256 if ($type == 'attachment') {
5257 $hide_empty = false;
5258 add_menu_page('Media Folders', 'Media Folders', 'publish_pages', "{$edit}?post_type=attachment&media_folder=", false, 'dashicons-portfolio', "{$itemKey}.5");
5259 } else {
5260 add_menu_page($upper.' Folders', "{$upper} Folders", 'publish_pages', "{$edit}?post_type={$type}&type=folder", false, 'dashicons-portfolio', "{$itemKey}.5");
5261 }
5262
5263 $terms = get_terms(
5264 [
5265 'taxonomy' => $tax_slug,
5266 'hide_empty' => $hide_empty,
5267 'parent' => 0,
5268 'orderby' => 'meta_value_num',
5269 'order' => 'ASC',
5270 'hierarchical' => false,
5271 'meta_query' => [
5272 [
5273 'key' => 'wcp_custom_order',
5274 'type' => 'NUMERIC',
5275 ],
5276 ],
5277 ]
5278 );
5279
5280 if ($terms) {
5281 foreach ($terms as $term) {
5282 if (isset($term->trash_count) && !empty($term->trash_count)) {
5283 if ($type == 'attachment') {
5284 add_submenu_page("{$edit}?type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type=attachment&media_folder={$term->slug}", false);
5285 } else {
5286 add_submenu_page("{$edit}?post_type={$type}&type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type={$type}&{$tax_slug}={$term->slug}", false);
5287 }
5288 }
5289 }
5290 }
5291 }//end foreach
5292
5293 }//end create_menu_for_folders()
5294
5295
5296 /**
5297 * Add Folder Styles
5298 *
5299 * @since 1.0.0
5300 * @access public
5301 */
5302 function folders_admin_styles($page)
5303 {
5304 $minified = ".min";
5305 if(IS_FOLDERS_DEVELOPER_MODE) {
5306 $minified = "";
5307 }
5308
5309 if($page == "folders-settings_page_folders-upgrade-to-pro" || ($page == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == 'upgrade-to-pro')) {
5310 wp_enqueue_style('folder-pricing-table', plugin_dir_url(dirname(__FILE__)).'assets/css/pricing-table'.esc_attr($minified).'.css', [], WCP_FOLDER_VERSION);
5311 $queryArgs = [
5312 'family' => 'Poppins:wght@400;500;600;700&display=swap',
5313 'subset' => 'latin,latin-ext',
5314 ];
5315 wp_enqueue_style('google-poppins-fonts', add_query_arg($queryArgs, "//fonts.googleapis.com/css2"), [], WCP_FOLDER_VERSION);
5316 } else if ($page == "toplevel_page_wcp_folders_settings" || $page == "settings_page_wcp_folders_settings") {
5317 wp_enqueue_style('folder-settings', plugin_dir_url(dirname(__FILE__)).'assets/css/settings'.esc_attr($minified).'.css', [], WCP_FOLDER_VERSION);
5318 wp_enqueue_style('folder-select2', plugin_dir_url(dirname(__FILE__)).'assets/css/select2.min.css', [], WCP_FOLDER_VERSION);
5319 wp_enqueue_style('folders-icon', plugin_dir_url(dirname(__FILE__)).'assets/css/folder-icon.min.css', [], WCP_FOLDER_VERSION);
5320 wp_enqueue_style('folders-spectrum', plugin_dir_url(dirname(__FILE__)).'assets/css/spectrum.min.css', [], WCP_FOLDER_VERSION);
5321 } else if ($page == "folders-settings_page_folders-upgrade-to-pro" || $page == "toplevel_page_wcp_folders_settings" || $page == "settings_page_wcp_folders_settings" || ($page == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == "upgrade-to-pro")) {
5322 wp_enqueue_style('wcp-select2', plugin_dir_url(dirname(__FILE__)).'assets/css/select2.min.css', [], WCP_FOLDER_VERSION);
5323 if ($page == "folders-settings_page_folders-upgrade-to-pro" || ($page == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == "upgrade-to-pro")) {
5324 wp_enqueue_style('wcp-admin-setting', plugin_dir_url(dirname(__FILE__)).'assets/css/admin-setting.min.css', [], WCP_FOLDER_VERSION);
5325 }
5326 }
5327
5328 if (self::is_active_for_screen()) {
5329 wp_enqueue_style('wcp-folders-fa', plugin_dir_url(dirname(__FILE__)).'assets/css/folder-icon.min.css', [], WCP_FOLDER_VERSION);
5330 wp_enqueue_style('wcp-folders-admin', plugin_dir_url(dirname(__FILE__)).'assets/css/design'.esc_attr($minified).'.css', [], WCP_FOLDER_VERSION);
5331 wp_enqueue_style('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)).'assets/css/jstree.min.css', [], WCP_FOLDER_VERSION);
5332 wp_enqueue_style('folder-overlayscrollbars', WCP_FOLDER_URL.'assets/css/overlayscrollbars.min.css', [], WCP_FOLDER_VERSION);
5333 wp_enqueue_style('wcp-folders-css', plugin_dir_url(dirname(__FILE__)).'assets/css/folders'.esc_attr($minified).'.css', [], WCP_FOLDER_VERSION);
5334 }
5335
5336 if ($page == "media_page_folders-media-cleaning") {
5337 wp_enqueue_style('wcp-folders-media', plugin_dir_url(dirname(__FILE__)).'assets/css/media-clean.min.css', [], WCP_FOLDER_VERSION);
5338 }
5339
5340 wp_register_style('wcp-css-handle', false);
5341 wp_enqueue_style('wcp-css-handle');
5342 $css = "
5343 .wcp-folder-upgrade-button {color: #FF5983; font-weight: bold; display: inline-block;border: solid 1px #FF5983;border-radius: 4px;padding: 0 5px;}
5344 ";
5345 if (self::is_active_for_screen()) {
5346 global $typenow;
5347 $width = get_option("wcp_dynamic_width_for_".$typenow);
5348 $width = esc_attr($width);
5349 $width = intval($width);
5350 $width = empty($width)||!is_numeric($width) ? 280 : $width;
5351 if ($width > 1200) {
5352 $width = 280;
5353 }
5354
5355 $width = intval($width);
5356 $display_status = "wcp_dynamic_display_status_".$typenow;
5357 $display_status = get_option($display_status);
5358 if ($display_status != "hide") {
5359 if (!empty($width) && is_numeric($width)) {
5360 if (function_exists('is_rtl') && is_rtl()) {
5361 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:".($width + 20)."px}";
5362 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}";
5363 } else {
5364 $css .= "body.wp-admin #wpcontent {padding-left:".($width + 20)."px}";
5365 }
5366 }
5367 } else {
5368 if (function_exists('is_rtl') && is_rtl()) {
5369 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:20px}";
5370 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}";
5371 } else {
5372 $css .= "body.wp-admin #wpcontent {padding-left:20px}";
5373 }
5374 }
5375
5376 if (!empty($width) && is_numeric($width)) {
5377 if ($width > 1200) {
5378 $width = 280;
5379 }
5380
5381 $width = intval($width);
5382 $css .= ".wcp-content {width: ".esc_attr($width)."px}";
5383 }
5384
5385 global $typenow;
5386 $post_type = self::get_custom_post_type($typenow);
5387 $css .= "body:not(.woocommerce-page) .wp-list-table th#taxonomy-".esc_attr($post_type)." { width: 130px !important; } @media screen and (max-width: 1180px) { body:not(.woocommerce-page) .wp-list-table th#taxonomy-".esc_attr($post_type)." { width: 90px !important; }} @media screen and (max-width: 960px) { body:not(.woocommerce-page) .wp-list-table th#taxonomy-".esc_attr($post_type)." { width: auto !important; }}";
5388 }//end if
5389
5390 wp_add_inline_style('wcp-css-handle', $css);
5391
5392 if (self::is_active_for_screen()) {
5393 global $typenow;
5394 add_filter('views_edit-'.$typenow, [$this, 'wcp_check_for_child_folders']);
5395 }
5396
5397 }//end folders_admin_styles()
5398
5399
5400 /**
5401 * Get Child folder information
5402 *
5403 * @since 1.0.0
5404 * @access public
5405 * @return $folders
5406 */
5407 function wcp_check_for_child_folders($content)
5408 {
5409 $termId = 0;
5410 global $typenow;
5411 $post_type = self::get_custom_post_type($typenow);
5412 $term = filter_input(INPUT_GET, $post_type);
5413 if (!empty($term)) {
5414 $term = get_term_by("slug", $term, $post_type);
5415 if (!empty($term)) {
5416 $termId = $term->term_id;
5417 }
5418 }
5419
5420 $terms = get_terms(
5421 [
5422 'taxonomy' => $post_type,
5423 'hide_empty' => false,
5424 'parent' => $termId,
5425 'orderby' => 'meta_value_num',
5426 'order' => 'ASC',
5427 'hierarchical' => false,
5428 'update_count_callback' => '_update_generic_term_count',
5429 'meta_query' => [
5430 [
5431 'key' => 'wcp_custom_order',
5432 'type' => 'NUMERIC',
5433 ],
5434 ],
5435 ]
5436 );
5437 $optionName = "wcp_folder_display_status_".$typenow;
5438 $optionValue = get_option($optionName);
5439 $class = (!empty($optionValue) && $optionValue == "hide") ? "" : "active";
5440 $customize_folders = get_option('customize_folders');
5441 $show_in_page = isset($customize_folders['show_in_page']) ? $customize_folders['show_in_page'] : "hide";
5442 if (empty($show_in_page)) {
5443 $show_in_page = "hide";
5444 }
5445
5446 if ($show_in_page == "show") {
5447 echo '<div class="tree-structure-content '.esc_attr($class).'"><div class="tree-structure" id="list-folder-'.esc_attr($termId).'" data-id="'.esc_attr($termId).'">';
5448 echo '<ul>';
5449 foreach ($terms as $term) {
5450 ?>
5451 <li class="grid-view" data-id="<?php echo esc_attr($term->term_id) ?>" id="folder_<?php echo esc_attr($term->term_id) ?>">
5452 <div class="folder-item is-folder" data-id="<?php echo esc_attr($term->term_id) ?>">
5453 <a title='<?php echo esc_attr($term->name) ?>' id="folder_view_<?php echo esc_attr($term->term_id) ?>" class="folder-view" data-id="<?php echo esc_attr($term->term_id) ?>">
5454 <span class="folder item-name"><span id="wcp_folder_text_<?php echo esc_attr($term->term_id) ?>" class="folder-title"><?php echo esc_attr($term->name) ?></span></span>
5455 </a>
5456 </div>
5457 </li>
5458 <?php
5459 }
5460
5461 echo '</ul>';
5462 echo '<div class="clear clearfix"></div>';
5463 echo '</div>';
5464 echo '<div class="folders-toggle-button"><span></span></div>';
5465 echo '</div>';
5466 }//end if
5467
5468 $allowedTags = [
5469 'a' => [
5470 'href' => [],
5471 'title' => [],
5472 'target' => [],
5473 'class' => []
5474 ],
5475 "span" => [
5476 'class' => []
5477 ]
5478 ];
5479
5480 if(isset($content['mine'])) {
5481 unset($content['mine']);
5482 }
5483 if (!empty($content) && is_array($content)) {
5484 echo '<ul class="subsubsub">';
5485 foreach ($content as $k => $v) {
5486 echo "<li class='".esc_attr($k)."'>".wp_kses($v, $allowedTags)."</li>";
5487 }
5488
5489 echo '</ul>';
5490 }
5491
5492 }//end wcp_check_for_child_folders()
5493
5494
5495 /**
5496 * Add Folder Scripts to admin
5497 *
5498 * @since 1.0.0
5499 * @access public
5500 * @return $folders
5501 */
5502 function folders_admin_scripts($hook)
5503 {
5504 $minified = ".min";
5505 if(IS_FOLDERS_DEVELOPER_MODE) {
5506 $minified = "";
5507 }
5508
5509 if ($hook == "toplevel_page_wcp_folders_settings" || $hook == "settings_page_wcp_folders_settings") {
5510 wp_enqueue_script('folders-spectrum', plugin_dir_url(dirname(__FILE__)).'assets/js/spectrum.min.js', ['jquery'], WCP_FOLDER_VERSION, true);
5511 }
5512
5513 if ($hook == "folders-settings_page_folders-upgrade-to-pro" || $hook == "toplevel_page_wcp_folders_settings" || $hook == "settings_page_wcp_folders_settings" || ($hook == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == "upgrade-to-pro")) {
5514 wp_enqueue_script('folders-select2', plugin_dir_url(dirname(__FILE__)).'assets/js/select2.min.js', ['jquery'], WCP_FOLDER_VERSION, true);
5515 }
5516
5517 if ($hook == "folders-settings_page_folders-upgrade-to-pro" || ($hook == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == "upgrade-to-pro")) {
5518 wp_enqueue_script('folders-slick', plugin_dir_url(dirname(__FILE__)).'assets/js/slick.min.js', ['jquery'], WCP_FOLDER_VERSION, true);
5519 }
5520
5521 $isShown = FOLDER_SIGNUP_CLASS::check_modal_status();
5522 if ($isShown) {
5523 wp_enqueue_script('folders-mailcheck-js', plugin_dir_url(dirname(__FILE__)).'assets/js/mailcheck.js', ['jquery'], WCP_FOLDER_VERSION, true);
5524 }
5525
5526 if (self::is_active_for_screen()) {
5527 remove_filter("terms_clauses", "TO_apply_order_filter");
5528
5529 global $typenow;
5530 // Free/Pro Version change
5531 wp_dequeue_script("jquery-jstree");
5532 wp_enqueue_script('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)).'assets/js/jstree.min.js', ['jquery'], WCP_FOLDER_VERSION, true);
5533 wp_enqueue_script('folders-overlayscrollbars', WCP_FOLDER_URL.'assets/js/jquery.overlayscrollbars.min.js', [], WCP_FOLDER_VERSION, true);
5534 wp_enqueue_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)).'assets/js/folders'.esc_attr($minified).'.js', ['jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'], WCP_FOLDER_VERSION, true);
5535 wp_enqueue_script('wcp-jquery-touch', plugin_dir_url(dirname(__FILE__)).'assets/js/jquery.ui.touch-punch.min.js', ['jquery'], WCP_FOLDER_VERSION, true);
5536
5537 $post_type = self::get_custom_post_type($typenow);
5538
5539 if(in_array($typenow, ["page", "post", "attachment"])) {
5540 $page_views = get_option("get_folders_page_views");
5541 if($page_views != -1 && $page_views != 3 && $page_views != 4) {
5542 $page_views = ($page_views)?intval($page_views):0;
5543 if ($typenow == "post" && count($_GET) == 0) {
5544 $page_views++;
5545 } else if ($typenow == "page" && count($_GET) == 1) {
5546 $page_views++;
5547 } else if ($typenow == "attachment" && count($_GET) == 0) {
5548 $page_views++;
5549 }
5550 if($page_views == 1) {
5551 add_option("get_folders_page_views", $page_views);
5552 } else {
5553 update_option("get_folders_page_views", $page_views);
5554 }
5555 }
5556 }
5557
5558 $post_status = "";
5559 if (isset($_GET['post_status']) && !empty($_GET['post_status'])) {
5560 $post_status = folders_sanitize_text('post_status', 'get');
5561 }
5562
5563 if ($typenow == "attachment") {
5564 $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
5565 global $current_user;
5566 if (isset($current_user->ID)) {
5567 $userMode = get_user_option('media_library_mode', get_current_user_id()) ? get_user_option('media_library_mode', get_current_user_id()) : 'grid';
5568 if($userMode == "list") {
5569 $admin_url = admin_url("upload.php?post_type=attachment");
5570 $search = filter_input(INPUT_GET, "s");
5571 if (!empty($search)) {
5572 $admin_url .= "&s=".esc_attr($search);
5573 }
5574
5575 if (!empty($post_status)) {
5576 $admin_url .= "&post_status=".sanitize_text_field($post_status);
5577 }
5578
5579 if(isset($_REQUEST['paged']) && !empty($_REQUEST['paged']) && is_numeric($_REQUEST['paged'])) {
5580 $paged = (int)sanitize_text_field($_REQUEST['paged']);
5581 if(!empty($paged)) {
5582 $admin_url .= "&paged=".esc_attr($paged);
5583 }
5584 }
5585
5586 $admin_url .= "&".esc_attr($post_type)."=";
5587 }
5588 }
5589 } else {
5590 $admin_url = admin_url("edit.php?post_type=".$typenow);
5591 $search = filter_input(INPUT_GET, "s");
5592 if (!empty($search)) {
5593 $admin_url .= "&s=".esc_attr($search);
5594 }
5595
5596 if (!empty($post_status)) {
5597 $admin_url .= "&post_status=".sanitize_text_field($post_status);
5598 }
5599
5600 if(isset($_REQUEST['paged']) && !empty($_REQUEST['paged']) && is_numeric($_REQUEST['paged'])) {
5601 $paged = (int)sanitize_text_field($_REQUEST['paged']);
5602 if(!empty($paged)) {
5603 $admin_url .= "&paged=".esc_attr($paged);
5604 }
5605 }
5606
5607 $admin_url .= "&".esc_attr($post_type)."=";
5608 }
5609
5610 $current_url = $admin_url;
5611 $post_value = filter_input(INPUT_GET, $post_type);
5612 if (!empty($post_value)) {
5613 $current_url .= esc_attr($post_value);
5614 }
5615
5616 $is_active = 1;
5617 $folders = -1;
5618 // For free: upgrade URL, for Pro: Register Key URL
5619 $register_url = $this->getFoldersUpgradeURL();
5620
5621 $is_rtl = 0;
5622 if (function_exists('is_rtl') && is_rtl()) {
5623 $is_rtl = 1;
5624 }
5625
5626 $can_manage_folder = current_user_can("manage_categories") ? 1 : 0;
5627 $width = get_option("wcp_dynamic_width_for_".$typenow);
5628 $width = intval($width);
5629 $width = empty($width)||!is_numeric($width) ? 280 : $width;
5630 if ($width > 1200) {
5631 $width = 280;
5632 }
5633
5634 $post_type = self::get_custom_post_type($typenow);
5635 $taxonomy_status = 0;
5636 $selected_taxonomy = "";
5637 $post_value = filter_input(INPUT_GET, $post_type);
5638 if (empty($post_value)) {
5639 $taxonomy_status = 1;
5640 } else {
5641 $selected_taxonomy = esc_attr($post_value);
5642
5643 $term = get_term_by('slug', $selected_taxonomy, $post_type);
5644 if (!empty($term) && is_object($term)) {
5645 $selected_taxonomy = $term->term_id;
5646 } else {
5647 $selected_taxonomy = "";
5648 }
5649 }
5650
5651 $customize_folders = get_option('customize_folders');
5652 $show_in_page = isset($customize_folders['show_in_page']) ? $customize_folders['show_in_page'] : "hide";
5653 if (empty($show_in_page)) {
5654 $show_in_page = "hide";
5655 }
5656
5657 $taxonomies = self::get_terms_hierarchical($post_type);
5658 $use_folder_undo = !isset($customize_folders['use_folder_undo']) ? "yes" : $customize_folders['use_folder_undo'];
5659 $defaultTimeout = !isset($customize_folders['default_timeout']) ? 5 : intval($customize_folders['default_timeout']);
5660 if (empty($defaultTimeout) || !is_numeric($defaultTimeout) || $defaultTimeout < 0) {
5661 $defaultTimeout = 5;
5662 }
5663
5664 $defaultTimeout = ($defaultTimeout * 1000);
5665
5666 $folder_settings = [];
5667 foreach ($taxonomies as $taxonomy) {
5668 $folder_info = get_term_meta($taxonomy->term_id, "folder_info", true);
5669 $folder_info = shortcode_atts([
5670 'is_sticky' => 0,
5671 'is_high' => 0,
5672 'is_locked' => 0,
5673 'is_active' => 0,
5674 'has_color' => ''
5675 ], $folder_info);
5676
5677 $folder_settings[] = [
5678 'folder_id' => $taxonomy->term_id,
5679 'is_sticky' => intval($folder_info['is_sticky']),
5680 'is_high' => intval($folder_info['is_high']),
5681 'is_locked' => intval($folder_info['is_locked']),
5682 'is_active' => intval($folder_info['is_active']),
5683 'has_color' => $folder_info['has_color'],
5684 'nonce' => wp_create_nonce('wcp_folder_term_'.$taxonomy->term_id),
5685 'is_deleted' => 0,
5686 'slug' => $taxonomy->slug,
5687 'folder_count' => intval($taxonomy->trash_count),
5688 ];
5689 }
5690
5691 $default_folders = get_option("default_folders");
5692 $default_folder = "";
5693 if (isset($default_folders["attachment"])) {
5694 $default_folder = $default_folders["attachment"];
5695 }
5696
5697 $use_shortcuts = !isset($customize_folders['use_shortcuts']) ? "yes" : $customize_folders['use_shortcuts'];
5698
5699 $custom_sort = isset($customize_folders['force_sorting'])?$customize_folders['force_sorting']:"off";
5700 $current_sort = "";
5701 if($custom_sort != "on") {
5702 $custom_sort = "off";
5703 } else {
5704 $current_sort = get_option("wcp_custom_sort_".$typenow, "");
5705 }
5706
5707 $currentPage = filter_input(INPUT_GET, 'paged');
5708 if (!empty($currentPage)) {
5709 $currentPage = intval($currentPage);
5710 } else {
5711 $currentPage = 1;
5712 }
5713
5714 $lang = $this->js_strings();
5715
5716 $hasStars = self::check_for_setting("has_stars", "general");
5717 $hasChild = self::check_for_setting("has_child", "general");
5718 $hasChild = empty($hasChild) ? 0 : 1;
5719 $hasStars = empty($hasStars) ? 0 : 1;
5720 $colors = $this->selected_colors();
5721
5722 wp_localize_script(
5723 'wcp-folders-custom',
5724 'wcp_settings',
5725 [
5726 'ajax_url' => admin_url('admin-ajax.php'),
5727 'upgrade_url' => $this->getFoldersUpgradeURL(),
5728 'post_type' => $typenow,
5729 'custom_type' => $post_type,
5730 'page_url' => $admin_url,
5731 'current_url' => $current_url,
5732 'ajax_image' => plugin_dir_url(dirname(__FILE__))."assets/images/ajax-loader.gif",
5733 'is_key_active' => $is_active,
5734 'folders' => $folders,
5735 'register_url' => $register_url,
5736 'isRTL' => $is_rtl,
5737 'nonce' => wp_create_nonce('wcp_folder_nonce_'.$typenow),
5738 'can_manage_folder' => $can_manage_folder,
5739 'folder_width' => $width,
5740 'taxonomy_status' => $taxonomy_status,
5741 'selected_taxonomy' => $selected_taxonomy,
5742 'show_in_page' => $show_in_page,
5743 'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png',
5744 'taxonomies' => $taxonomies,
5745 'folder_settings' => $folder_settings,
5746 'hasStars' => $hasStars,
5747 'hasChildren' => $hasChild,
5748 'currentPage' => $currentPage,
5749 'useFolderUndo' => $use_folder_undo,
5750 'defaultTimeout' => $defaultTimeout,
5751 'default_folder' => $default_folder,
5752 'use_shortcuts' => $use_shortcuts,
5753 'post_status' => $post_status,
5754 'lang' => $lang,
5755 'review_nonce' => wp_create_nonce("folders_review_box"),
5756 'review_box_nonce' => wp_create_nonce("folders_review_box_message"),
5757 'selected_colors' => $colors,
5758 'custom_sort' => $custom_sort,
5759 'current_sort' => $current_sort
5760 ]
5761 );
5762 } else {
5763 self::is_add_update_screen();
5764 }//end if
5765
5766 if ($hook == "media-new.php") {
5767 if (self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
5768 wp_enqueue_style('folders-media', WCP_FOLDER_URL.'assets/css/new-media.min.css', [], WCP_FOLDER_VERSION);
5769 $is_active = 1;
5770 $folders = -1;
5771
5772 $hasStars = self::check_for_setting("has_stars", "general");
5773 $hasChild = self::check_for_setting("has_child", "general");
5774 $hasChild = empty($hasChild) ? 0 : 1;
5775 $hasStars = empty($hasStars) ? 0 : 1;
5776
5777 wp_enqueue_script('wcp-folders-add-new-media', plugin_dir_url(dirname(__FILE__)).'assets/js/new-media'.esc_attr($minified).'.js', ['jquery'], WCP_FOLDER_VERSION, true);
5778 wp_localize_script(
5779 'wcp-folders-add-new-media',
5780 'folders_media_options',
5781 [
5782 'terms' => self::get_terms_hierarchical('media_folder'),
5783 'taxonomy' => get_taxonomy('media_folder'),
5784 'ajax_url' => admin_url("admin-ajax.php"),
5785 'activate_url' => $this->getFoldersUpgradeURL(),
5786 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
5787 'is_key_active' => $is_active,
5788 'folders' => $folders,
5789 'hasStars' => $hasStars,
5790 'hasChildren' => $hasChild,
5791 'lang' => [
5792 "pro_message" => esc_html__("WordPress doesn't allow you to upload SVG files, upgrade to Folders Pro and experience added SVG file upload support!", "folders"),
5793 "activate_key" => esc_html__("Upgrade now!", "folders"),
5794 ],
5795 ]
5796 );
5797 }//end if
5798 }//end if
5799
5800 }//end folders_admin_scripts()
5801
5802
5803 /**
5804 * Translated strings for javascript
5805 *
5806 * @since 1.0.0
5807 * @access public
5808 */
5809 public function js_strings()
5810 {
5811 return [
5812 "ALL_FOLDERS" => esc_html__("All Folders", "folders"),
5813 "NEW_FOLDER" => esc_html__("New folder", "folders"),
5814 "CHANGE_COLOR" => esc_html__("Icon Color","folders"),
5815 "REMOVE_COLOR" => esc_html__("Remove Icon Color","folders"),
5816 "ADD_CUSTOM_COLORS" => esc_html__("Add more colors (Pro)", "folders"),
5817 "NEW_SUB_FOLDER" => esc_html__("New Sub-folder", "folders"),
5818 "RENAME" => esc_html__("Rename", "folders"),
5819 "REMOVE_STICKY_FOLDER" => esc_html__("Remove Sticky Folder", "folders"),
5820 "STICKY_FOLDER" => esc_html__("Sticky Folder", "folders"),
5821 "REMOVE_STAR" => esc_html__("Remove Star", "folders"),
5822 "ADD_STAR" => esc_html__("Add Star", "folders"),
5823 "LOCK_FOLDER" => esc_html__("Lock Folder", "folders"),
5824 "UNLOCK_FOLDER" => esc_html__("Unlock Folder", "folders"),
5825 "DUPLICATE_FOLDER" => esc_html__("Duplicate folder", "folders"),
5826 "DOWNLOAD_ZIP" => esc_html__("Download Zip", "folders"),
5827 "OPEN_THIS_FOLDER" => esc_html__("Open this folder by default", "folders"),
5828 "REMOVE_THIS_FOLDER" => esc_html__("Remove default folder", "folders"),
5829 "CUT" => esc_html__("Cut", "folders"),
5830 "COPY" => esc_html__("Copy", "folders"),
5831 "PASTE" => esc_html__("Paste", "folders"),
5832 "DELETE" => esc_html__("Delete", "folders"),
5833 "BULK_ORGANIZE" => esc_html__("Bulk Organize", "folders"),
5834 "DRAG_AND_DROP" => esc_html__("Drag and drop your media files to the relevant folders", "folders"),
5835 "SELECT_ALL" => esc_html__("Select All", "folders"),
5836 "MOVE_SELECTED_FILES" => esc_html__("Move Selected files to:", "folders"),
5837 "UPLOADING_FILES" => esc_html__("Uploading files", "folders"),
5838 "SELECT_ITEMS_TO_MOVE" => esc_html__("Please select items to move in folder", "folders"),
5839 "LOADING_FILES" => esc_html__("Loading...", "folders"),
5840 "SELECT_FOLDER" => esc_html__("Select Folder", "folders"),
5841 "UNASSIGNED" => esc_html__("(Unassigned)", "folders"),
5842 "SELECT_ITEMS" => esc_html__("Select Items to move", "folders"),
5843 "ONE_ITEM" => esc_html__("1 Item", "folders"),
5844 "ITEMS" => esc_html__("Items", "folders"),
5845 "SELECTED" => esc_html__("Selected", "folders"),
5846 "MOVE_TO_FOLDER" => esc_html__("Move to Folder", "folders"),
5847 "DELETE_FOLDER_MESSAGE" => esc_html__("Are you sure you want to delete the selected folder?", "folders"),
5848 "ITEM_NOT_DELETED" => esc_html__("Items in the folder will not be deleted.", "folders"),
5849 "DELETE_FOLDERS_MESSAGE" => esc_html__("Are you sure you want to delete the selected folders?", "folders"),
5850 "ITEMS_NOT_DELETED" => esc_html__("Items in the selected folders will not be deleted.", "folders"),
5851 "SELECT_AT_LEAST_ONE_FOLDER" => esc_html__("Please select at least one folder to delete", "folders"),
5852 "YES_DELETE_IT" => esc_html__("Yes, Delete it!", "folders"),
5853 "SUBMIT" => esc_html__("Submit", "folders"),
5854 "EXPAND" => esc_html__("Expand", "folders"),
5855 "COLLAPSE" => esc_html__("Collapse", "folders"),
5856 "DUPLICATING_FOLDER" => esc_html__("Duplicating to a new folder", "folders"),
5857 "ADD_NEW_FOLDER" => esc_html__("Add a new folder", "folders"),
5858 "ACTIVATE" => [
5859 "REMOVE_STAR" => esc_html__("Remove Star (Activate)", "folders"),
5860 "ADD_STAR" => esc_html__("Add a Star (Activate)", "folders"),
5861 "STICKY_FOLDER" => esc_html__("Sticky Folder (Activate)", "folders"),
5862 "NEW_SUB_FOLDER" => esc_html__("New Sub-folder (Activate)", "folders"),
5863 "LOCK_FOLDER" => esc_html__("Lock Folder (Activate)", "folders"),
5864 "DUPLICATE_FOLDER" => esc_html__("Duplicate folder (Activate)", "folders"),
5865 "DOWNLOAD_ZIP" => esc_html__("Download Zip (Activate)", "folders"),
5866 ],
5867 "PRO" => [
5868 "ADD_STAR" => esc_html__("Add a Star (Pro)", "folders"),
5869 "REMOVE_STAR" => esc_html__("Remove Star (Pro)", "folders"),
5870 "STICKY_FOLDER" => esc_html__("Sticky Folder (Pro)", "folders"),
5871 "NEW_SUB_FOLDER" => esc_html__("New Sub-folder (Pro)", "folders"),
5872 "LOCK_FOLDER" => esc_html__("Lock Folder (Pro)", "folders"),
5873 "DUPLICATE_FOLDER" => esc_html__("Duplicate folder (Pro)", "folders"),
5874 "DOWNLOAD_ZIP" => esc_html__("Download Zip (Pro)", "folders"),
5875 "OPEN_THIS_FOLDER" => esc_html__("Open this folder by default (Pro)", "folders"),
5876 ],
5877 ];
5878
5879 }//end js_strings()
5880
5881 /**
5882 * Selected colors for folders
5883 *
5884 * @since 2.9.8
5885 * @access public
5886 */
5887 public function selected_colors() {
5888 $customize_folders = get_option('customize_folders');
5889 $defaultColors = ["#202020", "#86cd91", "#1E88E5", "#ff6060"];
5890 $colors = isset($customize_folders['folder_colors'])?$customize_folders['folder_colors']:$defaultColors;
5891 return $colors;
5892 }//end selected_colors()
5893
5894
5895 /**
5896 * Redirect to folders settings page on Plugin activation
5897 *
5898 * @since 1.0.0
5899 * @access public
5900 */
5901 public function plugin_action_links($links)
5902 {
5903 array_unshift($links, '<a href="'.admin_url("admin.php?page=wcp_folders_settings").'" >'.esc_html__('Settings', 'folders').'</a>');
5904 $links['need_help'] = '<a target="_blank" href="https://premio.io/help/folders/?utm_source=pluginspage" >'.__('Need help?', 'folders').'</a>';
5905
5906 // PRO link for only for FREE
5907 $links['pro'] = '<a class="wcp-folder-upgrade-button" href="'.$this->getFoldersUpgradeURL().'" >'.__('Upgrade', 'folders').'</a>';
5908 return $links;
5909
5910 }//end plugin_action_links()
5911
5912
5913 /**
5914 * Create instance of Folder class
5915 *
5916 * @since 1.0.0
5917 * @access public
5918 * @return $folders
5919 */
5920 public static function get_instance()
5921 {
5922 if (empty(self::$instance)) {
5923 // Do not change Class name here
5924 self::$instance = new WCP_Folders();
5925 }
5926
5927 return self::$instance;
5928
5929 }//end get_instance()
5930
5931
5932 /**
5933 * Will check for empty folder order
5934 *
5935 * @since 1.0.0
5936 * @access public
5937 */
5938 public function check_and_set_post_type()
5939 {
5940 $options = get_option('folders_settings');
5941 $old_plugin_status = 0;
5942 $post_array = [];
5943 if (!empty($options) && is_array($options)) {
5944 foreach ($options as $key => $val) {
5945 if (!(strpos($key, 'folders4') === false) && $old_plugin_status == 0) {
5946 $old_plugin_status = 1;
5947 }
5948
5949 if (in_array($key, ["folders4page", "folders4post", "folders4attachment"])) {
5950 $post_array[] = str_replace("folders4", "", $key);
5951 }
5952 }
5953 } else {
5954 $post_array = [
5955 "page",
5956 "post",
5957 "attachment",
5958 ];
5959 }
5960
5961 if ($old_plugin_status == 1) {
5962 $old_plugin_var = get_option("folder_old_plugin_status");
5963 if (empty($old_plugin_var) || $old_plugin_var == null) {
5964 update_option("folder_old_plugin_status", "1");
5965 }
5966
5967 update_option('folders_settings', $post_array);
5968 self::set_default_values_if_not_exists();
5969 }
5970
5971 if (!empty($post_array) && get_option('folders_settings') === false) {
5972 update_option('folders_settings', $post_array);
5973 }
5974
5975 }//end check_and_set_post_type()
5976
5977
5978 /**
5979 * Migrate data for old versions
5980 *
5981 * @since 1.0.0
5982 * @access public
5983 */
5984 public static function activate()
5985 {
5986 premio_folders_plugin_check_for_setting();
5987 $folder_setting = get_option("folders_settings");
5988 if ($folder_setting === false) {
5989 add_option("wcp_folder_version_267", 1);
5990 }
5991
5992 $option = get_option("folder_redirect_status");
5993 if ($option === false) {
5994 add_option("folder_intro_box", "show");
5995 }
5996
5997 if(WCP_FOLDER_VERSION == "3.0") {
5998 $hide_folder_color_pop_up = get_option("hide_folder_color_pop_up");
5999 if(!($hide_folder_color_pop_up)) {
6000 add_option("hide_folder_color_pop_up", "yes");
6001 } else {
6002 update_option("hide_folder_color_pop_up", "yes");
6003 }
6004 }
6005
6006 if(!defined("DOING_AJAX")) {
6007 delete_option("folder_redirect_status");
6008 add_option("folder_redirect_status", 1);
6009 }
6010
6011 }//end activate()
6012
6013
6014 /**
6015 * Remove folder data on deactivation
6016 *
6017 * @since 1.0.0
6018 * @access public
6019 */
6020 public static function deactivate()
6021 {
6022 $customize_folders = get_option('customize_folders');
6023 $DS = DIRECTORY_SEPARATOR;
6024 $dirName = ABSPATH."wp-content{$DS}plugins{$DS}folders-pro{$DS}";
6025 $is_pro = get_option("folders_pro_is_in_process");
6026 if (!is_dir($dirName) && $is_pro === false && isset($customize_folders['remove_folders_when_removed']) && $customize_folders['remove_folders_when_removed'] == "on") {
6027 self::$folders = 0;
6028 self::remove_folder_by_taxonomy("media_folder");
6029 self::remove_folder_by_taxonomy("folder");
6030 self::remove_folder_by_taxonomy("post_folder");
6031 $post_types = get_post_types([], 'objects');
6032 $post_array = [
6033 "page",
6034 "post",
6035 "attachment",
6036 ];
6037 foreach ($post_types as $post_type) {
6038 if (!in_array($post_type->name, $post_array)) {
6039 self::remove_folder_by_taxonomy($post_type->name.'_folder');
6040 }
6041 }
6042
6043 delete_option('customize_folders');
6044 delete_option('default_folders');
6045 delete_option('folder_redirect_status');
6046 delete_option('folders_settings');
6047 delete_option('premio_folder_options');
6048 delete_option('folders_settings_updated');
6049 }//end if
6050
6051 }//end deactivate()
6052
6053
6054 /**
6055 * Register folder settings
6056 *
6057 * @since 1.0.0
6058 * @access public
6059 */
6060 function folders_register_settings()
6061 {
6062 register_setting('folders_settings', 'folders_settings1', 'folders_settings_validate');
6063 register_setting('default_folders', 'default_folders');
6064 register_setting('customize_folders', 'customize_folders');
6065
6066 self::check_and_set_post_type();
6067
6068 $getData = filter_input_array(INPUT_GET);
6069 if (isset($getData['hide_menu']) && $getData['hide_menu'] == "scan-files" && isset($getData['nonce'])) {
6070 if (current_user_can('manage_options')) {
6071 $nonce = $getData['nonce'];
6072 if (wp_verify_nonce($nonce, "folders-scan-files")) {
6073 $customize_folders = get_option('customize_folders');
6074 $customize_folders['folders_media_cleaning'] = "no";
6075 update_option("customize_folders", $customize_folders);
6076 wp_redirect(admin_url("upload.php"));
6077 exit;
6078 }
6079 }
6080 }
6081 }//end folders_register_settings()
6082
6083
6084 /**
6085 * Folders upgrade URL
6086 *
6087 * @since 1.0.0
6088 * @access public
6089 * @return $url
6090 */
6091 function getFoldersUpgradeURL()
6092 {
6093 $customize_folders = get_option("customize_folders");
6094 if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
6095 return admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro");
6096 } else {
6097 return admin_url("admin.php?page=folders-upgrade-to-pro");
6098 }
6099
6100 }//end getFoldersUpgradeURL()
6101
6102
6103 /**
6104 * Returns folders settings URL
6105 *
6106 * @since 1.0.0
6107 * @access public
6108 * @return $url
6109 */
6110 function getFolderSettingsURL()
6111 {
6112 $customize_folders = get_option("customize_folders");
6113 if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
6114 return admin_url("options-general.php?page=wcp_folders_settings");
6115 } else {
6116 return admin_url("admin.php?page=wcp_folders_settings");
6117 }
6118
6119 }//end getFolderSettingsURL()
6120
6121
6122 /**
6123 * Checking folders setting is inside wordpress setting menu
6124 *
6125 * @since 1.0.0
6126 * @access public
6127 */
6128 function isFoldersInSettings()
6129 {
6130 $customize_folders = get_option("customize_folders");
6131 if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
6132 return true;
6133 }
6134
6135 return false;
6136
6137 }//end isFoldersInSettings()
6138
6139
6140 /**
6141 * Add Checkbox to table head for page, post, attachments
6142 *
6143 * @since 1.0.0
6144 * @access public
6145 * @return $defaults
6146 */
6147 function wcp_manage_columns_head($defaults, $d="")
6148 {
6149 global $typenow;
6150 $type = $typenow;
6151 $action = $this->getRequestVar("action");
6152 if ($action == 'inline-save') {
6153 $post_type = $this->getRequestVar('post_type');
6154 $type = self::sanitize_options($post_type);
6155 }
6156
6157 $options = get_option("folders_settings");
6158 if (is_array($options) && in_array($type, $options)) {
6159 $columns = ([
6160 '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>',
6161 ] + $defaults);
6162 return $columns;
6163 }
6164
6165 return $defaults;
6166
6167 }//end wcp_manage_columns_head()
6168
6169
6170 /**
6171 * Add Checkbox to table body content for page, post, attachments
6172 *
6173 * @since 1.0.0
6174 * @access public
6175 * @return $column_name
6176 */
6177 function wcp_manage_columns_content($column_name, $post_ID)
6178 {
6179 $postIDs = self::$postIds;
6180 if (!is_array($postIDs)) {
6181 $postIDs = [];
6182 }
6183
6184 if (!in_array($post_ID, $postIDs)) {
6185 $postIDs[] = $post_ID;
6186 self::$postIds = $postIDs;
6187 global $typenow;
6188 $type = $typenow;
6189 $action = $this->getRequestVar('action');
6190 if ($action == 'inline-save') {
6191 $post_type = $this->getRequestVar('post_type');
6192 $type = self::sanitize_options($post_type);
6193 }
6194
6195 $options = get_option("folders_settings");
6196 if (is_array($options) && in_array($type, $options)) {
6197 if ($column_name == 'wcp_move') {
6198 $title = get_the_title();
6199 if (strlen($title) > 20) {
6200 $title = substr($title, 0, 20)."...";
6201 }
6202
6203 echo "<div class='wcp-move-file' data-id='".esc_attr($post_ID)."'><span class='wcp-move dashicons dashicons-move' data-id='".esc_attr($post_ID)."'></span><span class='wcp-item' data-object-id='".esc_attr($post_ID)."'>".esc_attr($title)."</span></div>";
6204 }
6205 }
6206 }//end if
6207
6208 }//end wcp_manage_columns_content()
6209
6210
6211 /**
6212 * Exclude empty folders
6213 *
6214 * @since 1.0.0
6215 * @access public
6216 * @return $query
6217 */
6218 function taxonomy_archive_exclude_children($query)
6219 {
6220 $options = get_option("folders_settings");
6221 if (!empty($options)) {
6222 $taxonomy_slugs = [];
6223 foreach ($options as $option) {
6224 $taxonomy_slugs[] = self::get_custom_post_type($option);
6225 }
6226
6227 if (!empty($taxonomy_slugs)) {
6228 $i = 0;
6229 foreach ($query->tax_query->queries as $tax_query_item) {
6230 if (empty($taxonomy_slugs) || (isset($tax_query_item['taxonomy']) && in_array($tax_query_item['taxonomy'], $taxonomy_slugs))) {
6231 $query->tax_query->queries[$i]['include_children'] = 0;
6232 }
6233 }
6234 }
6235 }
6236
6237 }//end taxonomy_archive_exclude_children()
6238
6239
6240 /**
6241 * Add folder settins to WP menu
6242 *
6243 * @since 1.0.0
6244 * @access public
6245 */
6246 public function admin_menu()
6247 {
6248 $customize_folders = get_option("customize_folders");
6249 if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") {
6250 add_options_page(
6251 esc_html__('Folders Settings', 'folders'),
6252 esc_html__('Folders Settings', 'folders'),
6253 'manage_options',
6254 'wcp_folders_settings',
6255 [
6256 $this,
6257 'wcp_folders_settings',
6258 ]
6259 );
6260 } else {
6261 $menu_slug = 'wcp_folders_settings';
6262
6263 // Add menu item for settings page
6264 $page_title = esc_html__('Folders', 'folders');
6265 $menu_title = esc_html__('Folders Settings', 'folders');
6266 $capability = 'manage_options';
6267 $callback = [
6268 $this,
6269 "wcp_folders_settings",
6270 ];
6271 $icon_url = 'dashicons-category';
6272 $position = 99;
6273 add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $position);
6274
6275 $getData = filter_input_array(INPUT_GET);
6276 if (isset($getData['hide_folder_recommended_plugin']) && isset($getData['nonce'])) {
6277 if (current_user_can('manage_options')) {
6278 $nonce = $getData['nonce'];
6279 if (wp_verify_nonce($nonce, "folder_recommended_plugin")) {
6280 update_option('hide_folder_recommended_plugin', "1");
6281 }
6282 }
6283 }
6284
6285 $recommended_plugin = get_option("hide_folder_recommended_plugin");
6286 if ($recommended_plugin === false) {
6287 add_submenu_page(
6288 $menu_slug,
6289 esc_html__('Recommended Plugins', 'folders'),
6290 esc_html__('Recommended Plugins', 'folders'),
6291 'manage_options',
6292 'recommended-folder-plugins',
6293 [
6294 $this,
6295 'recommended_plugins',
6296 ]
6297 );
6298 }
6299
6300 // Do not Change Free/Pro Change for menu
6301 add_submenu_page(
6302 $menu_slug,
6303 esc_html__('Upgrade to Pro', 'folders'),
6304 esc_html__('Upgrade to Pro', 'folders'),
6305 'manage_options',
6306 'folders-upgrade-to-pro',
6307 [
6308 $this,
6309 'wcp_folders_upgrade_or_register',
6310 ]
6311 );
6312
6313 // Add menu for media cleaning
6314 $show_in_page = !isset($customize_folders['folders_media_cleaning']) ? "yes" : $customize_folders['folders_media_cleaning'];
6315
6316 if ($show_in_page == "yes") {
6317 add_submenu_page(
6318 "upload.php",
6319 esc_html__('Media Cleaning', 'folders'),
6320 esc_html__('Media Cleaning', 'folders'),
6321 'manage_options',
6322 'folders-media-cleaning',
6323 [
6324 $this,
6325 'wcp_folders_media_cleaning',
6326 ]
6327 );
6328 }
6329 }//end if
6330
6331 self::check_and_set_post_type();
6332
6333 $show_menu = get_option("folders_show_in_menu", true);
6334 if ($show_menu == 'on' && !isset($customize_folders['folders_show_in_menu'])) {
6335 $customize_folders['folders_show_in_menu'] = 'yes';
6336 update_option("customize_folders", $customize_folders);
6337 delete_option("folders_show_in_menu");
6338 }
6339
6340 if (isset($customize_folders['folders_show_in_menu']) && $customize_folders['folders_show_in_menu'] == "yes") {
6341 self::create_menu_for_folders();
6342 }
6343
6344 }//end admin_menu()
6345
6346
6347 /**
6348 * Media Cleaner Page
6349 *
6350 * @since 1.0.0
6351 * @access public
6352 * @return $html
6353 */
6354 public function wcp_folders_media_cleaning()
6355 {
6356 include_once dirname(dirname(__FILE__))."/templates/admin/media-cleaning.php";
6357
6358 }//end wcp_folders_media_cleaning()
6359
6360
6361 /**
6362 * Recommended plugins Page
6363 *
6364 * @since 1.0.0
6365 * @access public
6366 * @return $html
6367 */
6368 public function recommended_plugins()
6369 {
6370 include_once dirname(dirname(__FILE__))."/templates/admin/recommended-plugins.php";
6371
6372 }//end recommended_plugins()
6373
6374
6375 /**
6376 * Folders Upgrade Page
6377 *
6378 * @since 1.0.0
6379 * @access public
6380 * @return $html
6381 */
6382 public function wcp_folders_upgrade_or_register()
6383 {
6384 self::set_default_values_if_not_exists();
6385 include_once dirname(dirname(__FILE__))."/templates/admin/upgrade-to-pro.php";
6386
6387 }//end wcp_folders_upgrade_or_register()
6388
6389
6390 /**
6391 * Folders Settings Page
6392 *
6393 * @since 1.0.0
6394 * @access public
6395 * @return $html
6396 */
6397 public function wcp_folders_settings()
6398 {
6399 self::set_default_values_if_not_exists();
6400 // Only in Free, Get Folders update confirmation popup
6401 $is_shown = FOLDER_SIGNUP_CLASS::check_modal_status();
6402 if($is_shown) {
6403 include_once dirname(dirname(__FILE__))."/templates/admin/email-signup.php";
6404 } else {
6405 $setting_page = filter_input(INPUT_GET, 'setting_page');
6406 if (empty($setting_page)) {
6407 $setting_page = "folder-settings";
6408 }
6409 if($setting_page == "upgrade-to-pro") {
6410 $hasBackButton = true;
6411 include_once dirname(dirname(__FILE__)) . "/templates/admin/upgrade-to-pro.php";
6412 } else {
6413 $options = get_option('folders_settings');
6414 $options = (empty($options) || !is_array($options)) ? [] : $options;
6415 $post_types = get_post_types(['public' => true], 'objects');
6416 $terms_data = [];
6417 foreach ($post_types as $post_type) {
6418 if (in_array($post_type->name, $options)) {
6419 $term = $post_type->name;
6420 $term = self::get_custom_post_type($term);
6421 $categories = self::get_terms_hierarchical($term);
6422 $terms_data[$post_type->name] = $categories;
6423 } else {
6424 $terms_data[$post_type->name] = [];
6425 }
6426 }
6427
6428 $fonts = self::get_font_list();
6429
6430 $plugins = new WCP_Folder_Plugins();
6431 $plugin_info = $plugins->get_plugin_information();
6432 $is_plugin_exists = $plugins->is_exists;
6433 $settingURL = $this->getFolderSettingsURL();
6434
6435 $setting_page = in_array($setting_page, ["folder-settings", "customize-folders", "folders-import", "upgrade-to-pro", "folders-by-user","notification-settings"]) ? $setting_page : "folder-settings";
6436 $isInSettings = $this->isFoldersInSettings();
6437
6438 include_once dirname(dirname(__FILE__)) . "/templates/admin/general-settings.php";
6439
6440 $option = get_option("folder_intro_box");
6441 if ($option == "show") {
6442 include_once dirname(dirname(__FILE__)) . "/templates/admin/folder-popup.php";
6443 }
6444 }
6445 }//end if
6446
6447 }//end wcp_folders_settings()
6448
6449
6450 /**
6451 * Font List
6452 *
6453 * @since 1.0.0
6454 * @access public
6455 * @return $fonts
6456 */
6457 public static function get_font_list()
6458 {
6459 return [
6460 // System fonts.
6461 'Default' => 'Default',
6462 "System Stack" => 'Default',
6463 'Arial' => 'Default',
6464 'Tahoma' => 'Default',
6465 'Verdana' => 'Default',
6466 'Helvetica' => 'Default',
6467 'Times New Roman' => 'Default',
6468 'Trebuchet MS' => 'Default',
6469 'Georgia' => 'Default',
6470
6471 // Google Fonts (last update: 23/10/2018).
6472 'ABeeZee' => 'Google Fonts',
6473 'Abel' => 'Google Fonts',
6474 'Abhaya Libre' => 'Google Fonts',
6475 'Abril Fatface' => 'Google Fonts',
6476 'Aclonica' => 'Google Fonts',
6477 'Acme' => 'Google Fonts',
6478 'Actor' => 'Google Fonts',
6479 'Adamina' => 'Google Fonts',
6480 'Advent Pro' => 'Google Fonts',
6481 'Aguafina Script' => 'Google Fonts',
6482 'Akronim' => 'Google Fonts',
6483 'Aladin' => 'Google Fonts',
6484 'Aldrich' => 'Google Fonts',
6485 'Alef' => 'Google Fonts',
6486 'Alef Hebrew' => 'Google Fonts',
6487 // Hack for Google Early Access.
6488 'Alegreya' => 'Google Fonts',
6489 'Alegreya SC' => 'Google Fonts',
6490 'Alegreya Sans' => 'Google Fonts',
6491 'Alegreya Sans SC' => 'Google Fonts',
6492 'Alex Brush' => 'Google Fonts',
6493 'Alfa Slab One' => 'Google Fonts',
6494 'Alice' => 'Google Fonts',
6495 'Alike' => 'Google Fonts',
6496 'Alike Angular' => 'Google Fonts',
6497 'Allan' => 'Google Fonts',
6498 'Allerta' => 'Google Fonts',
6499 'Allerta Stencil' => 'Google Fonts',
6500 'Allura' => 'Google Fonts',
6501 'Almendra' => 'Google Fonts',
6502 'Almendra Display' => 'Google Fonts',
6503 'Almendra SC' => 'Google Fonts',
6504 'Amarante' => 'Google Fonts',
6505 'Amaranth' => 'Google Fonts',
6506 'Amatic SC' => 'Google Fonts',
6507 'Amethysta' => 'Google Fonts',
6508 'Amiko' => 'Google Fonts',
6509 'Amiri' => 'Google Fonts',
6510 'Amita' => 'Google Fonts',
6511 'Anaheim' => 'Google Fonts',
6512 'Andada' => 'Google Fonts',
6513 'Andika' => 'Google Fonts',
6514 'Angkor' => 'Google Fonts',
6515 'Annie Use Your Telescope' => 'Google Fonts',
6516 'Anonymous Pro' => 'Google Fonts',
6517 'Antic' => 'Google Fonts',
6518 'Antic Didone' => 'Google Fonts',
6519 'Antic Slab' => 'Google Fonts',
6520 'Anton' => 'Google Fonts',
6521 'Arapey' => 'Google Fonts',
6522 'Arbutus' => 'Google Fonts',
6523 'Arbutus Slab' => 'Google Fonts',
6524 'Architects Daughter' => 'Google Fonts',
6525 'Archivo' => 'Google Fonts',
6526 'Archivo Black' => 'Google Fonts',
6527 'Archivo Narrow' => 'Google Fonts',
6528 'Aref Ruqaa' => 'Google Fonts',
6529 'Arima Madurai' => 'Google Fonts',
6530 'Arimo' => 'Google Fonts',
6531 'Arizonia' => 'Google Fonts',
6532 'Armata' => 'Google Fonts',
6533 'Arsenal' => 'Google Fonts',
6534 'Artifika' => 'Google Fonts',
6535 'Arvo' => 'Google Fonts',
6536 'Arya' => 'Google Fonts',
6537 'Asap' => 'Google Fonts',
6538 'Asap Condensed' => 'Google Fonts',
6539 'Asar' => 'Google Fonts',
6540 'Asset' => 'Google Fonts',
6541 'Assistant' => 'Google Fonts',
6542 'Astloch' => 'Google Fonts',
6543 'Asul' => 'Google Fonts',
6544 'Athiti' => 'Google Fonts',
6545 'Atma' => 'Google Fonts',
6546 'Atomic Age' => 'Google Fonts',
6547 'Aubrey' => 'Google Fonts',
6548 'Audiowide' => 'Google Fonts',
6549 'Autour One' => 'Google Fonts',
6550 'Average' => 'Google Fonts',
6551 'Average Sans' => 'Google Fonts',
6552 'Averia Gruesa Libre' => 'Google Fonts',
6553 'Averia Libre' => 'Google Fonts',
6554 'Averia Sans Libre' => 'Google Fonts',
6555 'Averia Serif Libre' => 'Google Fonts',
6556 'Bad Script' => 'Google Fonts',
6557 'Bahiana' => 'Google Fonts',
6558 'Bai Jamjuree' => 'Google Fonts',
6559 'Baloo' => 'Google Fonts',
6560 'Baloo Bhai' => 'Google Fonts',
6561 'Baloo Bhaijaan' => 'Google Fonts',
6562 'Baloo Bhaina' => 'Google Fonts',
6563 'Baloo Chettan' => 'Google Fonts',
6564 'Baloo Da' => 'Google Fonts',
6565 'Baloo Paaji' => 'Google Fonts',
6566 'Baloo Tamma' => 'Google Fonts',
6567 'Baloo Tammudu' => 'Google Fonts',
6568 'Baloo Thambi' => 'Google Fonts',
6569 'Balthazar' => 'Google Fonts',
6570 'Bangers' => 'Google Fonts',
6571 'Barlow' => 'Google Fonts',
6572 'Barlow Condensed' => 'Google Fonts',
6573 'Barlow Semi Condensed' => 'Google Fonts',
6574 'Barrio' => 'Google Fonts',
6575 'Basic' => 'Google Fonts',
6576 'Battambang' => 'Google Fonts',
6577 'Baumans' => 'Google Fonts',
6578 'Bayon' => 'Google Fonts',
6579 'Belgrano' => 'Google Fonts',
6580 'Bellefair' => 'Google Fonts',
6581 'Belleza' => 'Google Fonts',
6582 'BenchNine' => 'Google Fonts',
6583 'Bentham' => 'Google Fonts',
6584 'Berkshire Swash' => 'Google Fonts',
6585 'Bevan' => 'Google Fonts',
6586 'Bigelow Rules' => 'Google Fonts',
6587 'Bigshot One' => 'Google Fonts',
6588 'Bilbo' => 'Google Fonts',
6589 'Bilbo Swash Caps' => 'Google Fonts',
6590 'BioRhyme' => 'Google Fonts',
6591 'BioRhyme Expanded' => 'Google Fonts',
6592 'Biryani' => 'Google Fonts',
6593 'Bitter' => 'Google Fonts',
6594 'Black And White Picture' => 'Google Fonts',
6595 'Black Han Sans' => 'Google Fonts',
6596 'Black Ops One' => 'Google Fonts',
6597 'Bokor' => 'Google Fonts',
6598 'Bonbon' => 'Google Fonts',
6599 'Boogaloo' => 'Google Fonts',
6600 'Bowlby One' => 'Google Fonts',
6601 'Bowlby One SC' => 'Google Fonts',
6602 'Brawler' => 'Google Fonts',
6603 'Bree Serif' => 'Google Fonts',
6604 'Bubblegum Sans' => 'Google Fonts',
6605 'Bubbler One' => 'Google Fonts',
6606 'Buda' => 'Google Fonts',
6607 'Buenard' => 'Google Fonts',
6608 'Bungee' => 'Google Fonts',
6609 'Bungee Hairline' => 'Google Fonts',
6610 'Bungee Inline' => 'Google Fonts',
6611 'Bungee Outline' => 'Google Fonts',
6612 'Bungee Shade' => 'Google Fonts',
6613 'Butcherman' => 'Google Fonts',
6614 'Butterfly Kids' => 'Google Fonts',
6615 'Cabin' => 'Google Fonts',
6616 'Cabin Condensed' => 'Google Fonts',
6617 'Cabin Sketch' => 'Google Fonts',
6618 'Caesar Dressing' => 'Google Fonts',
6619 'Cagliostro' => 'Google Fonts',
6620 'Cairo' => 'Google Fonts',
6621 'Calligraffitti' => 'Google Fonts',
6622 'Cambay' => 'Google Fonts',
6623 'Cambo' => 'Google Fonts',
6624 'Candal' => 'Google Fonts',
6625 'Cantarell' => 'Google Fonts',
6626 'Cantata One' => 'Google Fonts',
6627 'Cantora One' => 'Google Fonts',
6628 'Capriola' => 'Google Fonts',
6629 'Cardo' => 'Google Fonts',
6630 'Carme' => 'Google Fonts',
6631 'Carrois Gothic' => 'Google Fonts',
6632 'Carrois Gothic SC' => 'Google Fonts',
6633 'Carter One' => 'Google Fonts',
6634 'Catamaran' => 'Google Fonts',
6635 'Caudex' => 'Google Fonts',
6636 'Caveat' => 'Google Fonts',
6637 'Caveat Brush' => 'Google Fonts',
6638 'Cedarville Cursive' => 'Google Fonts',
6639 'Ceviche One' => 'Google Fonts',
6640 'Chakra Petch' => 'Google Fonts',
6641 'Changa' => 'Google Fonts',
6642 'Changa One' => 'Google Fonts',
6643 'Chango' => 'Google Fonts',
6644 'Charmonman' => 'Google Fonts',
6645 'Chathura' => 'Google Fonts',
6646 'Chau Philomene One' => 'Google Fonts',
6647 'Chela One' => 'Google Fonts',
6648 'Chelsea Market' => 'Google Fonts',
6649 'Chenla' => 'Google Fonts',
6650 'Cherry Cream Soda' => 'Google Fonts',
6651 'Cherry Swash' => 'Google Fonts',
6652 'Chewy' => 'Google Fonts',
6653 'Chicle' => 'Google Fonts',
6654 'Chivo' => 'Google Fonts',
6655 'Chonburi' => 'Google Fonts',
6656 'Cinzel' => 'Google Fonts',
6657 'Cinzel Decorative' => 'Google Fonts',
6658 'Clicker Script' => 'Google Fonts',
6659 'Coda' => 'Google Fonts',
6660 'Coda Caption' => 'Google Fonts',
6661 'Codystar' => 'Google Fonts',
6662 'Coiny' => 'Google Fonts',
6663 'Combo' => 'Google Fonts',
6664 'Comfortaa' => 'Google Fonts',
6665 'Coming Soon' => 'Google Fonts',
6666 'Concert One' => 'Google Fonts',
6667 'Condiment' => 'Google Fonts',
6668 'Content' => 'Google Fonts',
6669 'Contrail One' => 'Google Fonts',
6670 'Convergence' => 'Google Fonts',
6671 'Cookie' => 'Google Fonts',
6672 'Copse' => 'Google Fonts',
6673 'Corben' => 'Google Fonts',
6674 'Cormorant' => 'Google Fonts',
6675 'Cormorant Garamond' => 'Google Fonts',
6676 'Cormorant Infant' => 'Google Fonts',
6677 'Cormorant SC' => 'Google Fonts',
6678 'Cormorant Unicase' => 'Google Fonts',
6679 'Cormorant Upright' => 'Google Fonts',
6680 'Courgette' => 'Google Fonts',
6681 'Cousine' => 'Google Fonts',
6682 'Coustard' => 'Google Fonts',
6683 'Covered By Your Grace' => 'Google Fonts',
6684 'Crafty Girls' => 'Google Fonts',
6685 'Creepster' => 'Google Fonts',
6686 'Crete Round' => 'Google Fonts',
6687 'Crimson Text' => 'Google Fonts',
6688 'Croissant One' => 'Google Fonts',
6689 'Crushed' => 'Google Fonts',
6690 'Cuprum' => 'Google Fonts',
6691 'Cute Font' => 'Google Fonts',
6692 'Cutive' => 'Google Fonts',
6693 'Cutive Mono' => 'Google Fonts',
6694 'Damion' => 'Google Fonts',
6695 'Dancing Script' => 'Google Fonts',
6696 'Dangrek' => 'Google Fonts',
6697 'David Libre' => 'Google Fonts',
6698 'Dawning of a New Day' => 'Google Fonts',
6699 'Days One' => 'Google Fonts',
6700 'Dekko' => 'Google Fonts',
6701 'Delius' => 'Google Fonts',
6702 'Delius Swash Caps' => 'Google Fonts',
6703 'Delius Unicase' => 'Google Fonts',
6704 'Della Respira' => 'Google Fonts',
6705 'Denk One' => 'Google Fonts',
6706 'Devonshire' => 'Google Fonts',
6707 'Dhurjati' => 'Google Fonts',
6708 'Didact Gothic' => 'Google Fonts',
6709 'Diplomata' => 'Google Fonts',
6710 'Diplomata SC' => 'Google Fonts',
6711 'Do Hyeon' => 'Google Fonts',
6712 'Dokdo' => 'Google Fonts',
6713 'Domine' => 'Google Fonts',
6714 'Donegal One' => 'Google Fonts',
6715 'Doppio One' => 'Google Fonts',
6716 'Dorsa' => 'Google Fonts',
6717 'Dosis' => 'Google Fonts',
6718 'Dr Sugiyama' => 'Google Fonts',
6719 'Droid Arabic Kufi' => 'Google Fonts',
6720 // Hack for Google Early Access.
6721 'Droid Arabic Naskh' => 'Google Fonts',
6722 // Hack for Google Early Access.
6723 'Duru Sans' => 'Google Fonts',
6724 'Dynalight' => 'Google Fonts',
6725 'EB Garamond' => 'Google Fonts',
6726 'Eagle Lake' => 'Google Fonts',
6727 'East Sea Dokdo' => 'Google Fonts',
6728 'Eater' => 'Google Fonts',
6729 'Economica' => 'Google Fonts',
6730 'Eczar' => 'Google Fonts',
6731 'El Messiri' => 'Google Fonts',
6732 'Electrolize' => 'Google Fonts',
6733 'Elsie' => 'Google Fonts',
6734 'Elsie Swash Caps' => 'Google Fonts',
6735 'Emblema One' => 'Google Fonts',
6736 'Emilys Candy' => 'Google Fonts',
6737 'Encode Sans' => 'Google Fonts',
6738 'Encode Sans Condensed' => 'Google Fonts',
6739 'Encode Sans Expanded' => 'Google Fonts',
6740 'Encode Sans Semi Condensed' => 'Google Fonts',
6741 'Encode Sans Semi Expanded' => 'Google Fonts',
6742 'Engagement' => 'Google Fonts',
6743 'Englebert' => 'Google Fonts',
6744 'Enriqueta' => 'Google Fonts',
6745 'Erica One' => 'Google Fonts',
6746 'Esteban' => 'Google Fonts',
6747 'Euphoria Script' => 'Google Fonts',
6748 'Ewert' => 'Google Fonts',
6749 'Exo' => 'Google Fonts',
6750 'Exo 2' => 'Google Fonts',
6751 'Expletus Sans' => 'Google Fonts',
6752 'Fahkwang' => 'Google Fonts',
6753 'Fanwood Text' => 'Google Fonts',
6754 'Farsan' => 'Google Fonts',
6755 'Fascinate' => 'Google Fonts',
6756 'Fascinate Inline' => 'Google Fonts',
6757 'Faster One' => 'Google Fonts',
6758 'Fasthand' => 'Google Fonts',
6759 'Fauna One' => 'Google Fonts',
6760 'Faustina' => 'Google Fonts',
6761 'Federant' => 'Google Fonts',
6762 'Federo' => 'Google Fonts',
6763 'Felipa' => 'Google Fonts',
6764 'Fenix' => 'Google Fonts',
6765 'Finger Paint' => 'Google Fonts',
6766 'Fira Mono' => 'Google Fonts',
6767 'Fira Sans' => 'Google Fonts',
6768 'Fira Sans Condensed' => 'Google Fonts',
6769 'Fira Sans Extra Condensed' => 'Google Fonts',
6770 'Fjalla One' => 'Google Fonts',
6771 'Fjord One' => 'Google Fonts',
6772 'Flamenco' => 'Google Fonts',
6773 'Flavors' => 'Google Fonts',
6774 'Fondamento' => 'Google Fonts',
6775 'Fontdiner Swanky' => 'Google Fonts',
6776 'Forum' => 'Google Fonts',
6777 'Francois One' => 'Google Fonts',
6778 'Frank Ruhl Libre' => 'Google Fonts',
6779 'Freckle Face' => 'Google Fonts',
6780 'Fredericka the Great' => 'Google Fonts',
6781 'Fredoka One' => 'Google Fonts',
6782 'Freehand' => 'Google Fonts',
6783 'Fresca' => 'Google Fonts',
6784 'Frijole' => 'Google Fonts',
6785 'Fruktur' => 'Google Fonts',
6786 'Fugaz One' => 'Google Fonts',
6787 'GFS Didot' => 'Google Fonts',
6788 'GFS Neohellenic' => 'Google Fonts',
6789 'Gabriela' => 'Google Fonts',
6790 'Gaegu' => 'Google Fonts',
6791 'Gafata' => 'Google Fonts',
6792 'Galada' => 'Google Fonts',
6793 'Galdeano' => 'Google Fonts',
6794 'Galindo' => 'Google Fonts',
6795 'Gamja Flower' => 'Google Fonts',
6796 'Gentium Basic' => 'Google Fonts',
6797 'Gentium Book Basic' => 'Google Fonts',
6798 'Geo' => 'Google Fonts',
6799 'Geostar' => 'Google Fonts',
6800 'Geostar Fill' => 'Google Fonts',
6801 'Germania One' => 'Google Fonts',
6802 'Gidugu' => 'Google Fonts',
6803 'Gilda Display' => 'Google Fonts',
6804 'Give You Glory' => 'Google Fonts',
6805 'Glass Antiqua' => 'Google Fonts',
6806 'Glegoo' => 'Google Fonts',
6807 'Gloria Hallelujah' => 'Google Fonts',
6808 'Goblin One' => 'Google Fonts',
6809 'Gochi Hand' => 'Google Fonts',
6810 'Gorditas' => 'Google Fonts',
6811 'Gothic A1' => 'Google Fonts',
6812 'Goudy Bookletter 1911' => 'Google Fonts',
6813 'Graduate' => 'Google Fonts',
6814 'Grand Hotel' => 'Google Fonts',
6815 'Gravitas One' => 'Google Fonts',
6816 'Great Vibes' => 'Google Fonts',
6817 'Griffy' => 'Google Fonts',
6818 'Gruppo' => 'Google Fonts',
6819 'Gudea' => 'Google Fonts',
6820 'Gugi' => 'Google Fonts',
6821 'Gurajada' => 'Google Fonts',
6822 'Habibi' => 'Google Fonts',
6823 'Halant' => 'Google Fonts',
6824 'Hammersmith One' => 'Google Fonts',
6825 'Hanalei' => 'Google Fonts',
6826 'Hanalei Fill' => 'Google Fonts',
6827 'Handlee' => 'Google Fonts',
6828 'Hanuman' => 'Google Fonts',
6829 'Happy Monkey' => 'Google Fonts',
6830 'Harmattan' => 'Google Fonts',
6831 'Headland One' => 'Google Fonts',
6832 'Heebo' => 'Google Fonts',
6833 'Henny Penny' => 'Google Fonts',
6834 'Herr Von Muellerhoff' => 'Google Fonts',
6835 'Hi Melody' => 'Google Fonts',
6836 'Hind' => 'Google Fonts',
6837 'Hind Guntur' => 'Google Fonts',
6838 'Hind Madurai' => 'Google Fonts',
6839 'Hind Siliguri' => 'Google Fonts',
6840 'Hind Vadodara' => 'Google Fonts',
6841 'Holtwood One SC' => 'Google Fonts',
6842 'Homemade Apple' => 'Google Fonts',
6843 'Homenaje' => 'Google Fonts',
6844 'IBM Plex Mono' => 'Google Fonts',
6845 'IBM Plex Sans' => 'Google Fonts',
6846 'IBM Plex Sans Condensed' => 'Google Fonts',
6847 'IBM Plex Serif' => 'Google Fonts',
6848 'IM Fell DW Pica' => 'Google Fonts',
6849 'IM Fell DW Pica SC' => 'Google Fonts',
6850 'IM Fell Double Pica' => 'Google Fonts',
6851 'IM Fell Double Pica SC' => 'Google Fonts',
6852 'IM Fell English' => 'Google Fonts',
6853 'IM Fell English SC' => 'Google Fonts',
6854 'IM Fell French Canon' => 'Google Fonts',
6855 'IM Fell French Canon SC' => 'Google Fonts',
6856 'IM Fell Great Primer' => 'Google Fonts',
6857 'IM Fell Great Primer SC' => 'Google Fonts',
6858 'Iceberg' => 'Google Fonts',
6859 'Iceland' => 'Google Fonts',
6860 'Imprima' => 'Google Fonts',
6861 'Inconsolata' => 'Google Fonts',
6862 'Inder' => 'Google Fonts',
6863 'Indie Flower' => 'Google Fonts',
6864 'Inika' => 'Google Fonts',
6865 'Inknut Antiqua' => 'Google Fonts',
6866 'Irish Grover' => 'Google Fonts',
6867 'Istok Web' => 'Google Fonts',
6868 'Italiana' => 'Google Fonts',
6869 'Italianno' => 'Google Fonts',
6870 'Itim' => 'Google Fonts',
6871 'Jacques Francois' => 'Google Fonts',
6872 'Jacques Francois Shadow' => 'Google Fonts',
6873 'Jaldi' => 'Google Fonts',
6874 'Jim Nightshade' => 'Google Fonts',
6875 'Jockey One' => 'Google Fonts',
6876 'Jolly Lodger' => 'Google Fonts',
6877 'Jomhuria' => 'Google Fonts',
6878 'Josefin Sans' => 'Google Fonts',
6879 'Josefin Slab' => 'Google Fonts',
6880 'Joti One' => 'Google Fonts',
6881 'Jua' => 'Google Fonts',
6882 'Judson' => 'Google Fonts',
6883 'Julee' => 'Google Fonts',
6884 'Julius Sans One' => 'Google Fonts',
6885 'Junge' => 'Google Fonts',
6886 'Jura' => 'Google Fonts',
6887 'Just Another Hand' => 'Google Fonts',
6888 'Just Me Again Down Here' => 'Google Fonts',
6889 'K2D' => 'Google Fonts',
6890 'Kadwa' => 'Google Fonts',
6891 'Kalam' => 'Google Fonts',
6892 'Kameron' => 'Google Fonts',
6893 'Kanit' => 'Google Fonts',
6894 'Kantumruy' => 'Google Fonts',
6895 'Karla' => 'Google Fonts',
6896 'Karma' => 'Google Fonts',
6897 'Katibeh' => 'Google Fonts',
6898 'Kaushan Script' => 'Google Fonts',
6899 'Kavivanar' => 'Google Fonts',
6900 'Kavoon' => 'Google Fonts',
6901 'Kdam Thmor' => 'Google Fonts',
6902 'Keania One' => 'Google Fonts',
6903 'Kelly Slab' => 'Google Fonts',
6904 'Kenia' => 'Google Fonts',
6905 'Khand' => 'Google Fonts',
6906 'Khmer' => 'Google Fonts',
6907 'Khula' => 'Google Fonts',
6908 'Kirang Haerang' => 'Google Fonts',
6909 'Kite One' => 'Google Fonts',
6910 'Knewave' => 'Google Fonts',
6911 'KoHo' => 'Google Fonts',
6912 'Kodchasan' => 'Google Fonts',
6913 'Kosugi' => 'Google Fonts',
6914 'Kosugi Maru' => 'Google Fonts',
6915 'Kotta One' => 'Google Fonts',
6916 'Koulen' => 'Google Fonts',
6917 'Kranky' => 'Google Fonts',
6918 'Kreon' => 'Google Fonts',
6919 'Kristi' => 'Google Fonts',
6920 'Krona One' => 'Google Fonts',
6921 'Krub' => 'Google Fonts',
6922 'Kumar One' => 'Google Fonts',
6923 'Kumar One Outline' => 'Google Fonts',
6924 'Kurale' => 'Google Fonts',
6925 'La Belle Aurore' => 'Google Fonts',
6926 'Laila' => 'Google Fonts',
6927 'Lakki Reddy' => 'Google Fonts',
6928 'Lalezar' => 'Google Fonts',
6929 'Lancelot' => 'Google Fonts',
6930 'Lateef' => 'Google Fonts',
6931 'Lato' => 'Google Fonts',
6932 'League Script' => 'Google Fonts',
6933 'Leckerli One' => 'Google Fonts',
6934 'Ledger' => 'Google Fonts',
6935 'Lekton' => 'Google Fonts',
6936 'Lemon' => 'Google Fonts',
6937 'Lemonada' => 'Google Fonts',
6938 'Libre Barcode 128' => 'Google Fonts',
6939 'Libre Barcode 128 Text' => 'Google Fonts',
6940 'Libre Barcode 39' => 'Google Fonts',
6941 'Libre Barcode 39 Extended' => 'Google Fonts',
6942 'Libre Barcode 39 Extended Text' => 'Google Fonts',
6943 'Libre Barcode 39 Text' => 'Google Fonts',
6944 'Libre Baskerville' => 'Google Fonts',
6945 'Libre Franklin' => 'Google Fonts',
6946 'Life Savers' => 'Google Fonts',
6947 'Lilita One' => 'Google Fonts',
6948 'Lily Script One' => 'Google Fonts',
6949 'Limelight' => 'Google Fonts',
6950 'Linden Hill' => 'Google Fonts',
6951 'Lobster' => 'Google Fonts',
6952 'Lobster Two' => 'Google Fonts',
6953 'Londrina Outline' => 'Google Fonts',
6954 'Londrina Shadow' => 'Google Fonts',
6955 'Londrina Sketch' => 'Google Fonts',
6956 'Londrina Solid' => 'Google Fonts',
6957 'Lora' => 'Google Fonts',
6958 'Love Ya Like A Sister' => 'Google Fonts',
6959 'Loved by the King' => 'Google Fonts',
6960 'Lovers Quarrel' => 'Google Fonts',
6961 'Luckiest Guy' => 'Google Fonts',
6962 'Lusitana' => 'Google Fonts',
6963 'Lustria' => 'Google Fonts',
6964 'M PLUS 1p' => 'Google Fonts',
6965 'M PLUS Rounded 1c' => 'Google Fonts',
6966 'Macondo' => 'Google Fonts',
6967 'Macondo Swash Caps' => 'Google Fonts',
6968 'Mada' => 'Google Fonts',
6969 'Magra' => 'Google Fonts',
6970 'Maiden Orange' => 'Google Fonts',
6971 'Maitree' => 'Google Fonts',
6972 'Mako' => 'Google Fonts',
6973 'Mali' => 'Google Fonts',
6974 'Mallanna' => 'Google Fonts',
6975 'Mandali' => 'Google Fonts',
6976 'Manuale' => 'Google Fonts',
6977 'Marcellus' => 'Google Fonts',
6978 'Marcellus SC' => 'Google Fonts',
6979 'Marck Script' => 'Google Fonts',
6980 'Margarine' => 'Google Fonts',
6981 'Markazi Text' => 'Google Fonts',
6982 'Marko One' => 'Google Fonts',
6983 'Marmelad' => 'Google Fonts',
6984 'Martel' => 'Google Fonts',
6985 'Martel Sans' => 'Google Fonts',
6986 'Marvel' => 'Google Fonts',
6987 'Mate' => 'Google Fonts',
6988 'Mate SC' => 'Google Fonts',
6989 'Maven Pro' => 'Google Fonts',
6990 'McLaren' => 'Google Fonts',
6991 'Meddon' => 'Google Fonts',
6992 'MedievalSharp' => 'Google Fonts',
6993 'Medula One' => 'Google Fonts',
6994 'Meera Inimai' => 'Google Fonts',
6995 'Megrim' => 'Google Fonts',
6996 'Meie Script' => 'Google Fonts',
6997 'Merienda' => 'Google Fonts',
6998 'Merienda One' => 'Google Fonts',
6999 'Merriweather' => 'Google Fonts',
7000 'Merriweather Sans' => 'Google Fonts',
7001 'Metal' => 'Google Fonts',
7002 'Metal Mania' => 'Google Fonts',
7003 'Metamorphous' => 'Google Fonts',
7004 'Metrophobic' => 'Google Fonts',
7005 'Michroma' => 'Google Fonts',
7006 'Milonga' => 'Google Fonts',
7007 'Miltonian' => 'Google Fonts',
7008 'Miltonian Tattoo' => 'Google Fonts',
7009 'Mina' => 'Google Fonts',
7010 'Miniver' => 'Google Fonts',
7011 'Miriam Libre' => 'Google Fonts',
7012 'Mirza' => 'Google Fonts',
7013 'Miss Fajardose' => 'Google Fonts',
7014 'Mitr' => 'Google Fonts',
7015 'Modak' => 'Google Fonts',
7016 'Modern Antiqua' => 'Google Fonts',
7017 'Mogra' => 'Google Fonts',
7018 'Molengo' => 'Google Fonts',
7019 'Molle' => 'Google Fonts',
7020 'Monda' => 'Google Fonts',
7021 'Monofett' => 'Google Fonts',
7022 'Monoton' => 'Google Fonts',
7023 'Monsieur La Doulaise' => 'Google Fonts',
7024 'Montaga' => 'Google Fonts',
7025 'Montez' => 'Google Fonts',
7026 'Montserrat' => 'Google Fonts',
7027 'Montserrat Alternates' => 'Google Fonts',
7028 'Montserrat Subrayada' => 'Google Fonts',
7029 'Moul' => 'Google Fonts',
7030 'Moulpali' => 'Google Fonts',
7031 'Mountains of Christmas' => 'Google Fonts',
7032 'Mouse Memoirs' => 'Google Fonts',
7033 'Mr Bedfort' => 'Google Fonts',
7034 'Mr Dafoe' => 'Google Fonts',
7035 'Mr De Haviland' => 'Google Fonts',
7036 'Mrs Saint Delafield' => 'Google Fonts',
7037 'Mrs Sheppards' => 'Google Fonts',
7038 'Mukta' => 'Google Fonts',
7039 'Mukta Mahee' => 'Google Fonts',
7040 'Mukta Malar' => 'Google Fonts',
7041 'Mukta Vaani' => 'Google Fonts',
7042 'Muli' => 'Google Fonts',
7043 'Mystery Quest' => 'Google Fonts',
7044 'NTR' => 'Google Fonts',
7045 'Nanum Brush Script' => 'Google Fonts',
7046 'Nanum Gothic' => 'Google Fonts',
7047 'Nanum Gothic Coding' => 'Google Fonts',
7048 'Nanum Myeongjo' => 'Google Fonts',
7049 'Nanum Pen Script' => 'Google Fonts',
7050 'Neucha' => 'Google Fonts',
7051 'Neuton' => 'Google Fonts',
7052 'New Rocker' => 'Google Fonts',
7053 'News Cycle' => 'Google Fonts',
7054 'Niconne' => 'Google Fonts',
7055 'Niramit' => 'Google Fonts',
7056 'Nixie One' => 'Google Fonts',
7057 'Nobile' => 'Google Fonts',
7058 'Nokora' => 'Google Fonts',
7059 'Norican' => 'Google Fonts',
7060 'Nosifer' => 'Google Fonts',
7061 'Notable' => 'Google Fonts',
7062 'Nothing You Could Do' => 'Google Fonts',
7063 'Noticia Text' => 'Google Fonts',
7064 'Noto Kufi Arabic' => 'Google Fonts',
7065 // Hack for Google Early Access.
7066 'Noto Naskh Arabic' => 'Google Fonts',
7067 // Hack for Google Early Access.
7068 'Noto Sans' => 'Google Fonts',
7069 'Noto Sans Hebrew' => 'Google Fonts',
7070 // Hack for Google Early Access.
7071 'Noto Sans JP' => 'Google Fonts',
7072 'Noto Sans KR' => 'Google Fonts',
7073 'Noto Serif' => 'Google Fonts',
7074 'Noto Serif JP' => 'Google Fonts',
7075 'Noto Serif KR' => 'Google Fonts',
7076 'Nova Cut' => 'Google Fonts',
7077 'Nova Flat' => 'Google Fonts',
7078 'Nova Mono' => 'Google Fonts',
7079 'Nova Oval' => 'Google Fonts',
7080 'Nova Round' => 'Google Fonts',
7081 'Nova Script' => 'Google Fonts',
7082 'Nova Slim' => 'Google Fonts',
7083 'Nova Square' => 'Google Fonts',
7084 'Numans' => 'Google Fonts',
7085 'Nunito' => 'Google Fonts',
7086 'Nunito Sans' => 'Google Fonts',
7087 'Odor Mean Chey' => 'Google Fonts',
7088 'Offside' => 'Google Fonts',
7089 'Old Standard TT' => 'Google Fonts',
7090 'Oldenburg' => 'Google Fonts',
7091 'Oleo Script' => 'Google Fonts',
7092 'Oleo Script Swash Caps' => 'Google Fonts',
7093 'Open Sans' => 'Google Fonts',
7094 'Open Sans Condensed' => 'Google Fonts',
7095 'Open Sans Hebrew' => 'Google Fonts',
7096 // Hack for Google Early Access.
7097 'Open Sans Hebrew Condensed' => 'Google Fonts',
7098 // Hack for Google Early Access.
7099 'Oranienbaum' => 'Google Fonts',
7100 'Orbitron' => 'Google Fonts',
7101 'Oregano' => 'Google Fonts',
7102 'Orienta' => 'Google Fonts',
7103 'Original Surfer' => 'Google Fonts',
7104 'Oswald' => 'Google Fonts',
7105 'Over the Rainbow' => 'Google Fonts',
7106 'Overlock' => 'Google Fonts',
7107 'Overlock SC' => 'Google Fonts',
7108 'Overpass' => 'Google Fonts',
7109 'Overpass Mono' => 'Google Fonts',
7110 'Ovo' => 'Google Fonts',
7111 'Oxygen' => 'Google Fonts',
7112 'Oxygen Mono' => 'Google Fonts',
7113 'PT Mono' => 'Google Fonts',
7114 'PT Sans' => 'Google Fonts',
7115 'PT Sans Caption' => 'Google Fonts',
7116 'PT Sans Narrow' => 'Google Fonts',
7117 'PT Serif' => 'Google Fonts',
7118 'PT Serif Caption' => 'Google Fonts',
7119 'Pacifico' => 'Google Fonts',
7120 'Padauk' => 'Google Fonts',
7121 'Palanquin' => 'Google Fonts',
7122 'Palanquin Dark' => 'Google Fonts',
7123 'Pangolin' => 'Google Fonts',
7124 'Paprika' => 'Google Fonts',
7125 'Parisienne' => 'Google Fonts',
7126 'Passero One' => 'Google Fonts',
7127 'Passion One' => 'Google Fonts',
7128 'Pathway Gothic One' => 'Google Fonts',
7129 'Patrick Hand' => 'Google Fonts',
7130 'Patrick Hand SC' => 'Google Fonts',
7131 'Pattaya' => 'Google Fonts',
7132 'Patua One' => 'Google Fonts',
7133 'Pavanam' => 'Google Fonts',
7134 'Paytone One' => 'Google Fonts',
7135 'Peddana' => 'Google Fonts',
7136 'Peralta' => 'Google Fonts',
7137 'Permanent Marker' => 'Google Fonts',
7138 'Petit Formal Script' => 'Google Fonts',
7139 'Petrona' => 'Google Fonts',
7140 'Philosopher' => 'Google Fonts',
7141 'Piedra' => 'Google Fonts',
7142 'Pinyon Script' => 'Google Fonts',
7143 'Pirata One' => 'Google Fonts',
7144 'Plaster' => 'Google Fonts',
7145 'Play' => 'Google Fonts',
7146 'Playball' => 'Google Fonts',
7147 'Playfair Display' => 'Google Fonts',
7148 'Playfair Display SC' => 'Google Fonts',
7149 'Podkova' => 'Google Fonts',
7150 'Poiret One' => 'Google Fonts',
7151 'Poller One' => 'Google Fonts',
7152 'Poly' => 'Google Fonts',
7153 'Pompiere' => 'Google Fonts',
7154 'Pontano Sans' => 'Google Fonts',
7155 'Poor Story' => 'Google Fonts',
7156 'Poppins' => 'Google Fonts',
7157 'Port Lligat Sans' => 'Google Fonts',
7158 'Port Lligat Slab' => 'Google Fonts',
7159 'Pragati Narrow' => 'Google Fonts',
7160 'Prata' => 'Google Fonts',
7161 'Preahvihear' => 'Google Fonts',
7162 'Press Start 2P' => 'Google Fonts',
7163 'Pridi' => 'Google Fonts',
7164 'Princess Sofia' => 'Google Fonts',
7165 'Prociono' => 'Google Fonts',
7166 'Prompt' => 'Google Fonts',
7167 'Prosto One' => 'Google Fonts',
7168 'Proza Libre' => 'Google Fonts',
7169 'Puritan' => 'Google Fonts',
7170 'Purple Purse' => 'Google Fonts',
7171 'Quando' => 'Google Fonts',
7172 'Quantico' => 'Google Fonts',
7173 'Quattrocento' => 'Google Fonts',
7174 'Quattrocento Sans' => 'Google Fonts',
7175 'Questrial' => 'Google Fonts',
7176 'Quicksand' => 'Google Fonts',
7177 'Quintessential' => 'Google Fonts',
7178 'Qwigley' => 'Google Fonts',
7179 'Racing Sans One' => 'Google Fonts',
7180 'Radley' => 'Google Fonts',
7181 'Rajdhani' => 'Google Fonts',
7182 'Rakkas' => 'Google Fonts',
7183 'Raleway' => 'Google Fonts',
7184 'Raleway Dots' => 'Google Fonts',
7185 'Ramabhadra' => 'Google Fonts',
7186 'Ramaraja' => 'Google Fonts',
7187 'Rambla' => 'Google Fonts',
7188 'Rammetto One' => 'Google Fonts',
7189 'Ranchers' => 'Google Fonts',
7190 'Rancho' => 'Google Fonts',
7191 'Ranga' => 'Google Fonts',
7192 'Rasa' => 'Google Fonts',
7193 'Rationale' => 'Google Fonts',
7194 'Ravi Prakash' => 'Google Fonts',
7195 'Redressed' => 'Google Fonts',
7196 'Reem Kufi' => 'Google Fonts',
7197 'Reenie Beanie' => 'Google Fonts',
7198 'Revalia' => 'Google Fonts',
7199 'Rhodium Libre' => 'Google Fonts',
7200 'Ribeye' => 'Google Fonts',
7201 'Ribeye Marrow' => 'Google Fonts',
7202 'Righteous' => 'Google Fonts',
7203 'Risque' => 'Google Fonts',
7204 'Roboto' => 'Google Fonts',
7205 'Roboto Condensed' => 'Google Fonts',
7206 'Roboto Mono' => 'Google Fonts',
7207 'Roboto Slab' => 'Google Fonts',
7208 'Rochester' => 'Google Fonts',
7209 'Rock Salt' => 'Google Fonts',
7210 'Rokkitt' => 'Google Fonts',
7211 'Romanesco' => 'Google Fonts',
7212 'Ropa Sans' => 'Google Fonts',
7213 'Rosario' => 'Google Fonts',
7214 'Rosarivo' => 'Google Fonts',
7215 'Rouge Script' => 'Google Fonts',
7216 'Rozha One' => 'Google Fonts',
7217 'Rubik' => 'Google Fonts',
7218 'Rubik Mono One' => 'Google Fonts',
7219 'Ruda' => 'Google Fonts',
7220 'Rufina' => 'Google Fonts',
7221 'Ruge Boogie' => 'Google Fonts',
7222 'Ruluko' => 'Google Fonts',
7223 'Rum Raisin' => 'Google Fonts',
7224 'Ruslan Display' => 'Google Fonts',
7225 'Russo One' => 'Google Fonts',
7226 'Ruthie' => 'Google Fonts',
7227 'Rye' => 'Google Fonts',
7228 'Sacramento' => 'Google Fonts',
7229 'Sahitya' => 'Google Fonts',
7230 'Sail' => 'Google Fonts',
7231 'Saira' => 'Google Fonts',
7232 'Saira Condensed' => 'Google Fonts',
7233 'Saira Extra Condensed' => 'Google Fonts',
7234 'Saira Semi Condensed' => 'Google Fonts',
7235 'Salsa' => 'Google Fonts',
7236 'Sanchez' => 'Google Fonts',
7237 'Sancreek' => 'Google Fonts',
7238 'Sansita' => 'Google Fonts',
7239 'Sarala' => 'Google Fonts',
7240 'Sarina' => 'Google Fonts',
7241 'Sarpanch' => 'Google Fonts',
7242 'Satisfy' => 'Google Fonts',
7243 'Sawarabi Gothic' => 'Google Fonts',
7244 'Sawarabi Mincho' => 'Google Fonts',
7245 'Scada' => 'Google Fonts',
7246 'Scheherazade' => 'Google Fonts',
7247 'Schoolbell' => 'Google Fonts',
7248 'Scope One' => 'Google Fonts',
7249 'Seaweed Script' => 'Google Fonts',
7250 'Secular One' => 'Google Fonts',
7251 'Sedgwick Ave' => 'Google Fonts',
7252 'Sedgwick Ave Display' => 'Google Fonts',
7253 'Sevillana' => 'Google Fonts',
7254 'Seymour One' => 'Google Fonts',
7255 'Shadows Into Light' => 'Google Fonts',
7256 'Shadows Into Light Two' => 'Google Fonts',
7257 'Shanti' => 'Google Fonts',
7258 'Share' => 'Google Fonts',
7259 'Share Tech' => 'Google Fonts',
7260 'Share Tech Mono' => 'Google Fonts',
7261 'Shojumaru' => 'Google Fonts',
7262 'Short Stack' => 'Google Fonts',
7263 'Shrikhand' => 'Google Fonts',
7264 'Siemreap' => 'Google Fonts',
7265 'Sigmar One' => 'Google Fonts',
7266 'Signika' => 'Google Fonts',
7267 'Signika Negative' => 'Google Fonts',
7268 'Simonetta' => 'Google Fonts',
7269 'Sintony' => 'Google Fonts',
7270 'Sirin Stencil' => 'Google Fonts',
7271 'Six Caps' => 'Google Fonts',
7272 'Skranji' => 'Google Fonts',
7273 'Slabo 13px' => 'Google Fonts',
7274 'Slabo 27px' => 'Google Fonts',
7275 'Slackey' => 'Google Fonts',
7276 'Smokum' => 'Google Fonts',
7277 'Smythe' => 'Google Fonts',
7278 'Sniglet' => 'Google Fonts',
7279 'Snippet' => 'Google Fonts',
7280 'Snowburst One' => 'Google Fonts',
7281 'Sofadi One' => 'Google Fonts',
7282 'Sofia' => 'Google Fonts',
7283 'Song Myung' => 'Google Fonts',
7284 'Sonsie One' => 'Google Fonts',
7285 'Sorts Mill Goudy' => 'Google Fonts',
7286 'Source Code Pro' => 'Google Fonts',
7287 'Source Sans Pro' => 'Google Fonts',
7288 'Source Serif Pro' => 'Google Fonts',
7289 'Space Mono' => 'Google Fonts',
7290 'Special Elite' => 'Google Fonts',
7291 'Spectral' => 'Google Fonts',
7292 'Spectral SC' => 'Google Fonts',
7293 'Spicy Rice' => 'Google Fonts',
7294 'Spinnaker' => 'Google Fonts',
7295 'Spirax' => 'Google Fonts',
7296 'Squada One' => 'Google Fonts',
7297 'Sree Krushnadevaraya' => 'Google Fonts',
7298 'Sriracha' => 'Google Fonts',
7299 'Srisakdi' => 'Google Fonts',
7300 'Stalemate' => 'Google Fonts',
7301 'Stalinist One' => 'Google Fonts',
7302 'Stardos Stencil' => 'Google Fonts',
7303 'Stint Ultra Condensed' => 'Google Fonts',
7304 'Stint Ultra Expanded' => 'Google Fonts',
7305 'Stoke' => 'Google Fonts',
7306 'Strait' => 'Google Fonts',
7307 'Stylish' => 'Google Fonts',
7308 'Sue Ellen Francisco' => 'Google Fonts',
7309 'Suez One' => 'Google Fonts',
7310 'Sumana' => 'Google Fonts',
7311 'Sunflower' => 'Google Fonts',
7312 'Sunshiney' => 'Google Fonts',
7313 'Supermercado One' => 'Google Fonts',
7314 'Sura' => 'Google Fonts',
7315 'Suranna' => 'Google Fonts',
7316 'Suravaram' => 'Google Fonts',
7317 'Suwannaphum' => 'Google Fonts',
7318 'Swanky and Moo Moo' => 'Google Fonts',
7319 'Syncopate' => 'Google Fonts',
7320 'Tajawal' => 'Google Fonts',
7321 'Tangerine' => 'Google Fonts',
7322 'Taprom' => 'Google Fonts',
7323 'Tauri' => 'Google Fonts',
7324 'Taviraj' => 'Google Fonts',
7325 'Teko' => 'Google Fonts',
7326 'Telex' => 'Google Fonts',
7327 'Tenali Ramakrishna' => 'Google Fonts',
7328 'Tenor Sans' => 'Google Fonts',
7329 'Text Me One' => 'Google Fonts',
7330 'The Girl Next Door' => 'Google Fonts',
7331 'Tienne' => 'Google Fonts',
7332 'Tillana' => 'Google Fonts',
7333 'Timmana' => 'Google Fonts',
7334 'Tinos' => 'Google Fonts',
7335 'Titan One' => 'Google Fonts',
7336 'Titillium Web' => 'Google Fonts',
7337 'Trade Winds' => 'Google Fonts',
7338 'Trirong' => 'Google Fonts',
7339 'Trocchi' => 'Google Fonts',
7340 'Trochut' => 'Google Fonts',
7341 'Trykker' => 'Google Fonts',
7342 'Tulpen One' => 'Google Fonts',
7343 'Ubuntu' => 'Google Fonts',
7344 'Ubuntu Condensed' => 'Google Fonts',
7345 'Ubuntu Mono' => 'Google Fonts',
7346 'Ultra' => 'Google Fonts',
7347 'Uncial Antiqua' => 'Google Fonts',
7348 'Underdog' => 'Google Fonts',
7349 'Unica One' => 'Google Fonts',
7350 'UnifrakturCook' => 'Google Fonts',
7351 'UnifrakturMaguntia' => 'Google Fonts',
7352 'Unkempt' => 'Google Fonts',
7353 'Unlock' => 'Google Fonts',
7354 'Unna' => 'Google Fonts',
7355 'VT323' => 'Google Fonts',
7356 'Vampiro One' => 'Google Fonts',
7357 'Varela' => 'Google Fonts',
7358 'Varela Round' => 'Google Fonts',
7359 'Vast Shadow' => 'Google Fonts',
7360 'Vesper Libre' => 'Google Fonts',
7361 'Vibur' => 'Google Fonts',
7362 'Vidaloka' => 'Google Fonts',
7363 'Viga' => 'Google Fonts',
7364 'Voces' => 'Google Fonts',
7365 'Volkhov' => 'Google Fonts',
7366 'Vollkorn' => 'Google Fonts',
7367 'Vollkorn SC' => 'Google Fonts',
7368 'Voltaire' => 'Google Fonts',
7369 'Waiting for the Sunrise' => 'Google Fonts',
7370 'Wallpoet' => 'Google Fonts',
7371 'Walter Turncoat' => 'Google Fonts',
7372 'Warnes' => 'Google Fonts',
7373 'Wellfleet' => 'Google Fonts',
7374 'Wendy One' => 'Google Fonts',
7375 'Wire One' => 'Google Fonts',
7376 'Work Sans' => 'Google Fonts',
7377 'Yanone Kaffeesatz' => 'Google Fonts',
7378 'Yantramanav' => 'Google Fonts',
7379 'Yatra One' => 'Google Fonts',
7380 'Yellowtail' => 'Google Fonts',
7381 'Yeon Sung' => 'Google Fonts',
7382 'Yeseva One' => 'Google Fonts',
7383 'Yesteryear' => 'Google Fonts',
7384 'Yrsa' => 'Google Fonts',
7385 'Zeyada' => 'Google Fonts',
7386 'Zilla Slab' => 'Google Fonts',
7387 'Zilla Slab Highlight' => 'Google Fonts',
7388 ];
7389
7390 }//end get_font_list()
7391
7392
7393 /**
7394 * Set Default folder order if not exists
7395 *
7396 * @since 1.0.0
7397 * @access public
7398 * @return $fonts
7399 */
7400 public function set_default_values_if_not_exists()
7401 {
7402 if (is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
7403 $options = get_option('folders_settings');
7404 $options = empty($options) || !is_array($options) ? [] : $options;
7405 foreach ($options as $option) {
7406 $post_type = self::get_custom_post_type($option);
7407 $terms = get_terms(
7408 [
7409 'taxonomy' => $post_type,
7410 'hide_empty' => false,
7411 'meta_query' => [
7412 [
7413 'key' => 'wcp_custom_order',
7414 'compare' => 'NOT EXISTS',
7415 ],
7416 ],
7417 ]
7418 );
7419 if (!empty($terms)) {
7420 foreach ($terms as $term) {
7421 $order = get_term_meta($term->term_id, "wcp_custom_order", true);
7422 if (empty($order) || $order == null) {
7423 update_term_meta($term->term_id, "wcp_custom_order", "1");
7424 }
7425 }
7426 }
7427 }//end foreach
7428 }//end if
7429
7430 }//end set_default_values_if_not_exists()
7431
7432
7433 // Free and Pro major changes
7434
7435
7436 /**
7437 * Hide Folder intro Popup
7438 *
7439 * @since 1.0.0
7440 * @access public
7441 */
7442 public function premio_hide_child_popup()
7443 {
7444 $post_type = $this->getRequestVar('post_type');
7445 $nonce = $this->getRequestVar('nonce');
7446 if (!empty($post_type) && wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$post_type)) {
7447 $status = $this->getRequestVar('status');
7448 $status = ($status == 1) ? 1 : 0;
7449 if ($status) {
7450 add_option("premio_hide_child_popup", 1);
7451 } else {
7452 delete_option("premio_hide_child_popup");
7453 }
7454 }
7455
7456 echo esc_attr("1");
7457 die;
7458
7459 }//end premio_hide_child_popup()
7460
7461
7462 /**
7463 * Hide Folder intro Popup
7464 *
7465 * @since 1.0.0
7466 * @access public
7467 */
7468 public function folder_update_popup_status()
7469 {
7470 $nonce = $this->getRequestVar('nonce');
7471 if (!empty($nonce) && wp_verify_nonce($nonce, 'folder_update_popup_status')) {
7472 update_option("folder_intro_box", "hide");
7473 }
7474
7475 echo esc_attr("1");
7476 die;
7477
7478 }//end folder_update_popup_status()
7479
7480
7481 /**
7482 * Hide Folder import Popup
7483 *
7484 * @since 1.0.0
7485 * @access public
7486 */
7487 public function update_folders_import_status()
7488 {
7489 $nonce = $this->getRequestVar('nonce');
7490 if (!empty($nonce) && wp_verify_nonce($nonce, 'folders_import_3rd_party_data')) {
7491 update_option("folder_redirect_status", "3");
7492 }
7493
7494 echo esc_attr("1");
7495 die;
7496
7497 }//end update_folders_import_status()
7498
7499
7500 /**
7501 * Check folders has valid key
7502 *
7503 * @since 1.0.0
7504 * @access public
7505 */
7506 public function check_has_valid_key()
7507 {
7508 // Free/Pro: checking for key, for Free return 0, for Pro check for Key
7509 return 0;
7510
7511 }//end check_has_valid_key()
7512
7513
7514 /**
7515 * Get license information
7516 *
7517 * @since 1.0.0
7518 * @access public
7519 */
7520 public function get_license_key_information($licenseKey)
7521 {
7522 return [];
7523
7524 }//end get_license_key_information()
7525
7526
7527 /**
7528 * Get license key data
7529 *
7530 * @since 1.0.0
7531 * @access public
7532 */
7533 public function get_license_key_data($licenseKey='')
7534 {
7535 return [];
7536
7537 }//end get_license_key_data()
7538
7539
7540 /**
7541 * Check for license key data
7542 *
7543 * @since 1.0.0
7544 * @access public
7545 */
7546 public function check_for_license_key()
7547 {
7548 return false;
7549
7550 }//end check_for_license_key()
7551
7552
7553 }//end class
7554
7555
7556 if(!function_exists("folders_sanitize_text")) {
7557 function folders_sanitize_text($key ,$type = "post") {
7558 if($type == "post") {
7559 $string = filter_input(INPUT_POST, $key);
7560 } else {
7561 $string = filter_input(INPUT_GET, $key);
7562 }
7563 $string = stripslashes($string);
7564 $str = preg_replace('/\x00|<[^>]*>?/', '', $string);
7565 return str_replace(["'", '"'], ['&#39;', '&#34;'], $str);
7566 }
7567 }
7568