PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 2.5.7
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v2.5.7
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 6 years ago class-polylang.php 6 years ago class-review-box.php 6 years ago class-wpml.php 6 years ago folders.class.php 6 years ago form.class.php 6 years ago plugin.updates.php 6 years ago tree.class.php 6 years ago
folders.class.php
4053 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3 /* Free/Pro Class name change */
4 class WCP_Folders
5 {
6
7 private static $instance;
8
9 private static $license_key_data = null;
10
11 private static $folders;
12
13 public $tlfs = 0;
14
15 private static $postIds;
16
17 public function __construct()
18 {
19 spl_autoload_register(array($this, 'autoload'));
20 add_action('init', array($this, 'create_folder_terms'), 15);
21 add_action('admin_init', array($this, 'folders_register_settings'));
22 add_action('admin_menu', array($this, 'admin_menu'), 10000);
23 add_action('admin_enqueue_scripts', array($this, 'folders_admin_styles'));
24 add_action('admin_enqueue_scripts', array($this, 'folders_admin_scripts'));
25 add_filter('plugin_action_links_' . WCP_FOLDERS_PLUGIN_BASE, [$this, 'plugin_action_links']);
26 add_action('admin_footer', array($this, 'admin_footer'));
27
28 /* check for polygon media */
29 // $polylang_options = get_option("polylang");
30 // if(is_array($polylang_options) && isset($polylang_options['media_support']) && $polylang_options['media_support'] == 1) {
31 // $polylang_options['media_support'] = 0;
32 // update_option("polylang", $polylang_options);
33 // }
34
35 add_action('parse_tax_query', array($this, 'taxonomy_archive_exclude_children'));
36 add_action('admin_footer', array($this, 'admin_footer_for_media'));
37
38 /* Save Data */
39 add_action('wp_ajax_wcp_add_new_folder', array($this, 'wcp_add_new_folder'));
40 /* Update Data */
41 add_action('wp_ajax_wcp_update_folder', array($this, 'wcp_update_folder'));
42 /* Remove Data */
43 add_action('wp_ajax_wcp_remove_folder', array($this, 'wcp_remove_folder'));
44 /* Remove Multple Folder */
45 add_action('wp_ajax_wcp_remove_muliple_folder', array($this, 'remove_muliple_folder'));
46 /* Save State Data */
47 add_action('wp_ajax_save_wcp_folder_state', array($this, 'save_wcp_folder_state'));
48 /* Save State Data */
49 add_action('wp_ajax_wcp_save_parent_data', array($this, 'wcp_save_parent_data'));
50 /* Update Parent Data */
51 add_action('wp_ajax_wcp_update_parent_information', array($this, 'wcp_update_parent_information'));
52 /* Update Parent Data */
53 add_action('wp_ajax_wcp_save_folder_order', array($this, 'wcp_save_folder_order'));
54 /* Update Parent Data */
55 add_action('wp_ajax_wcp_mark_un_mark_folder', array($this, 'wcp_mark_un_mark_folder'));
56 /* Update Parent Data */
57 add_action('wp_ajax_wcp_make_sticky_folder', array($this, 'wcp_make_sticky_folder'));
58 /* Update Parent Data */
59 add_action('wp_ajax_wcp_change_post_folder', array($this, 'wcp_change_post_folder'));
60 /* Update Parent Data */
61 add_action('wp_ajax_wcp_change_multiple_post_folder', array($this, 'wcp_change_multiple_post_folder'));
62 /* Update width Data */
63 add_action('wp_ajax_wcp_change_post_width', array($this, 'wcp_change_post_width'));
64 /* Update width Data */
65 add_action('wp_ajax_wcp_change_folder_display_status', array($this, 'wcp_change_folder_display_status'));
66 /* Update width Data */
67 add_action('wp_ajax_wcp_change_all_status', array($this, 'wcp_change_all_status'));
68 /* Update width Data */
69 add_action('wp_ajax_save_folder_last_status', array($this, 'save_folder_last_status'));
70 /* Update width Data */
71 add_action('wp_ajax_wcp_folders_by_order', array($this, 'wcp_folders_by_order'));
72 self::$folders = 10;
73
74 /* Send message on plugin deactivate */
75 add_action( 'wp_ajax_folder_plugin_deactivate', array( $this, 'folder_plugin_deactivate' ) );
76 /* Update Parent Data */
77 add_action('wp_ajax_wcp_remove_post_folder', array($this, 'wcp_remove_post_folder'));
78 /* Send message on owner */
79 add_action( 'wp_ajax_wcp_folder_send_message_to_owner', array( $this, 'wcp_folder_send_message_to_owner' ) );
80 /* Get default list */
81 add_action( 'wp_ajax_wcp_get_default_list', array( $this, 'wcp_get_default_list' ) );
82 /* Get default list */
83 add_action( 'wp_ajax_get_folders_default_list', array( $this, 'get_folders_default_list' ) );
84 /* Auto select folder for new page, post */
85 add_action('new_to_auto-draft', array($this, 'new_to_auto_draft'), 10);
86 /* for media */
87 add_action('restrict_manage_posts', array($this, 'output_list_table_filters'), 10, 2);
88 add_filter('pre_get_posts', array($this, 'filter_attachments_list'));
89 add_action('wp_enqueue_media', array($this, 'output_backbone_view_filters'));
90 add_filter('ajax_query_attachments_args', array($this, 'filter_attachments_grid'));
91 add_filter('add_attachment', array($this, 'save_media_terms'));
92
93 /* to filter un assigned items*/
94 add_filter('pre_get_posts', array($this, 'filter_record_list'));
95 add_filter('pre-upload-ui', array($this, 'show_dropdown_on_media_screen'));
96 add_action('add_attachment', array($this, 'add_attachment_category'));
97
98
99
100 $options = get_option("folders_settings");
101
102 $options = is_array($options)?$options:array();
103
104 if (in_array("post", $options)) {
105 add_filter('manage_posts_columns', array($this, 'wcp_manage_columns_head'));
106 add_action('manage_posts_custom_column', array($this, 'wcp_manage_columns_content'), 10, 2);
107 add_filter( 'bulk_actions-edit-post', array($this, 'custom_bulk_action' ));
108 }
109
110 if (in_array("page", $options)) {
111 add_filter('manage_page_posts_columns', array($this, 'wcp_manage_columns_head'));
112 add_action('manage_page_posts_custom_column', array($this, 'wcp_manage_columns_content'), 10, 2);
113 add_filter( 'bulk_actions-edit-page', array($this, 'custom_bulk_action' ));
114 }
115
116 if (in_array("attachment", $options)) {
117 add_filter('manage_media_columns', array($this, 'wcp_manage_columns_head'));
118 add_action('manage_media_custom_column', array($this, 'wcp_manage_columns_content'), 10, 2);
119 //add_filter('bulk_actions-edit-media', array($this, 'custom_bulk_action' ));
120 }
121
122 foreach ($options as $option) {
123 if ($option != "post" && $option != "page" && $option != "attachment") {
124 add_filter('manage_edit-'.$option.'_columns', array($this, 'wcp_manage_columns_head'), 99999);
125 add_action('manage_'.$option.'_posts_custom_column', array($this, 'wcp_manage_columns_content'), 2, 2);
126 add_filter( 'bulk_actions-edit-'.$option, array($this, 'custom_bulk_action' ));
127 }
128 }
129
130 /* check for default folders */
131 add_filter('pre_get_posts', array($this, 'check_for_default_folders'));
132
133 add_action("wp_ajax_folder_update_status", array($this, 'folder_update_status'));
134
135 /* load language files */
136 add_action( 'plugins_loaded', array( $this, 'folders_text' ) );
137
138 add_action("wp_ajax_folder_update_popup_status", array($this, 'update_popup_status'));
139
140 add_filter('get_terms', array( $this, 'get_terms_filter_without_trash'), 10, 3);
141
142 add_filter('mla_media_modal_query_final_terms', array( $this, 'media_modal_query_final_terms'), 10, 3);
143 }
144
145 public static function hexToRgb($hex, $alpha = false) {
146 $hex = str_replace('#', '', $hex);
147 $length = strlen($hex);
148 $rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
149 $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
150 $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
151 if ( $alpha ) {
152 $rgb['a'] = $alpha;
153 }
154 return $rgb;
155 }
156
157 public function wcp_folders_by_order(){
158 $response = array();
159 $response['status'] = 0;
160 $response['error'] = 0;
161 $response['data'] = array();
162 $response['message'] = "";
163 $postData = filter_input_array(INPUT_POST);
164 $errorCounter = 0;
165
166 if (!isset($postData['order']) || empty($postData['order'])) {
167 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
168 $errorCounter++;
169 } else if (!isset($postData['type']) || empty($postData['type'])) {
170 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
171 $errorCounter++;
172 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
173 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
174 $errorCounter++;
175 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
176 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
177 $errorCounter++;
178 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
179 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
180 $errorCounter++;
181 } else {
182 $type = self::sanitize_options($postData['type']);
183 $nonce = self::sanitize_options($postData['nonce']);
184 if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
185 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
186 $errorCounter++;
187 }
188 }
189 if ($errorCounter == 0) {
190 $response['status'] = 1;
191
192 $order_field = $postData['order'];
193
194 $order_by = "";
195 $order = "ASC";
196
197 if($order_field == "a-z" || $order_field == "z-a") {
198 $order_by = 'title';
199 if($order_field == "z-a") {
200 $order = "DESC";
201 }
202 } else if($order_field == "n-o" || $order_field == "o-n") {
203 $order_by = 'ID';
204 if($order_field == "o-n") {
205 $order = "ASC";
206 } else {
207 $order = "DESC";
208 }
209 }
210
211 if(empty($order_by)) {
212 $order = "";
213 }
214
215 $folder_type = self::get_custom_post_type($postData['type']);
216 /* Do not change: Free/Pro Class name change */
217 $tree_data = WCP_Tree::get_full_tree_data($folder_type, $order_by, $order);
218
219 $response['data'] = $tree_data['string'];
220 }
221 echo json_encode($response); die;
222 }
223
224 public function save_folder_last_status(){
225 $postData = filter_input_array(INPUT_POST);
226 $error = 0;
227 if (!isset($postData['post_id']) || empty($postData['post_id'])) {
228 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
229 $error = 1;
230 } else if (!isset($postData['post_type']) || empty($postData['type'])) {
231 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
232 $error = 1;
233 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
234 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
235 $error = 1;
236 } else if ($postData['post_type'] == "page" && !current_user_can("edit_pages")) {
237 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
238 $error = 1;
239 } else if ($postData['post_type'] != "page" && !current_user_can("edit_posts")) {
240 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
241 $error = 1;
242 }
243 if($error == 0) {
244 $post_type = filter_input(INPUT_POST, 'post_type', FILTER_SANITIZE_STRING);
245 $post_id = filter_input(INPUT_POST, 'post_id', FILTER_SANITIZE_STRING);
246 if (!empty($post_type) && !empty($post_id)) {
247 delete_option("last_folder_status_for" . $post_type);
248 add_option("last_folder_status_for" . $post_type, $post_id);
249 }
250 }
251 }
252
253 public function media_modal_query_final_terms($request)
254 {
255 if (isset($_REQUEST['action']) && $_REQUEST['action'] == "mla-query-attachments") {
256 $query = isset($_REQUEST['query']) ? $_REQUEST['query'] : array();
257 if (isset($query['media_folder']) && !empty($query['media_folder'])) {
258 if ($query['media_folder'] == -1) {
259 $tax_query = array(
260 'taxonomy' => 'media_folder',
261 'operator' => 'NOT EXISTS',
262 );
263 $request['tax_query'] = array($tax_query);
264 $request = apply_filters('media_library_organizer_media_filter_attachments', $request, $_REQUEST);
265 } else {
266 $request['media_folder'] = $query['media_folder'];
267 }
268 }
269 }
270 return $request;
271 }
272
273 public function get_terms_filter_without_trash($terms, $taxonomies, $args) {
274 global $wpdb;
275 if ( ! is_array($terms) && count($terms) < 1 ) {
276 return $terms;
277 }
278
279 $post_table = $wpdb->prefix."posts";
280 $term_table = $wpdb->prefix."term_relationships";
281 $options = get_option(WCP_FOLDER_VAR);
282 $option_array = array();
283 if(!empty($options)) {
284 foreach ($options as $option) {
285 $option_array[] = self::get_custom_post_type($option);
286 }
287 }
288 foreach ($terms as $key=>$term ) {
289 if(isset($term->term_id) && isset($term->taxonomy) && !empty($term->taxonomy) && in_array($term->taxonomy, $option_array)) {
290 $trash_count = null;
291 if(has_filter("premio_folder_item_in_taxonomy")) {
292 $post_type = "";
293 $taxonomy = $term->taxonomy;
294
295 if ($taxonomy == "post_folder") {
296 $post_type = "post";
297 } else if ($taxonomy == "folder") {
298 $post_type = "page";
299 } else if ($taxonomy == "media_folder") {
300 $post_type = "attachment";
301 } else {
302 $post_type = trim($taxonomy, "'_folder'");
303 }
304 $arg = array(
305 'post_type' => $post_type,
306 'taxonomy' => $taxonomy,
307 );
308 $trash_count = apply_filters("premio_folder_item_in_taxonomy", $term->term_id, $arg);
309 }
310 if($trash_count === null) {
311 $result = $wpdb->get_var("SELECT COUNT(*) FROM {$post_table} p JOIN {$term_table} rl ON p.ID = rl.object_id WHERE rl.term_taxonomy_id = '{$term->term_id}' AND p.post_status != 'trash' LIMIT 1");
312 if (intval($result) > 0) {
313 $trash_count = intval($result);
314 } else {
315 $trash_count = 0;
316 }
317 }
318 $terms[$key]->trash_count = $trash_count;
319 }
320 }
321 return $terms;
322 }
323
324 public function custom_bulk_action($bulk_actions) {
325 $bulk_actions['move_to_folder'] = __( 'Move to Folder', 'email_to_eric');
326 return $bulk_actions;
327 }
328
329 public function folders_text() {
330 load_plugin_textdomain("folders", FALSE, dirname(plugin_basename(__FILE__)).'/languages/');
331 }
332
333 public function admin_footer_for_media(){
334 echo "<style>";
335 $customize_folders = get_option('customize_folders');
336 if(isset($customize_folders['dropdown_color']) && !empty($customize_folders['dropdown_color'])) {
337 ?>
338 #media-attachment-taxonomy-filter, .post-upload-ui .folder_for_media, select.media-select-folder { border-color: <?php echo esc_attr($customize_folders['dropdown_color']) ?>; color: <?php echo esc_attr($customize_folders['dropdown_color']) ?> }
339 .folder_for_media option {color:#000000;}
340 .folder_for_media option:first-child {
341 font-weight: bold;
342 }
343 <?php
344 }
345 echo "</style>";
346 }
347
348 public function check_for_default_folders() {
349 global $typenow, $current_screen;
350 $isAjax = (defined('DOING_AJAX') && DOING_AJAX)?1:0;
351 $options = get_option('folders_settings');
352 $options = (empty($options) || !is_array($options))?array():$options;
353 $post_status = filter_input(INPUT_GET, 'post_status', FILTER_SANITIZE_STRING);
354 $last_status = get_option("last_folder_status_for".$typenow);
355 if(empty($post_status) && !$isAjax && (in_array($typenow, $options) || !empty($last_status)) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) {
356
357 if(!empty($last_status)) {
358 $status = 1;
359 if($last_status != "-1" && $last_status != "all") {
360 $type = self::get_custom_post_type($typenow);
361 $term = get_term_by('slug', $last_status, $type);
362 if (empty($term) || !is_object($term)) {
363 $status = 0;
364 }
365 }
366 delete_option("last_folder_status_for".$typenow);
367 if($last_status == "all") {
368 $last_status = "";
369 }
370 if($status) {
371 if ($typenow == "attachment") {
372 if (!isset($_REQUEST['media_folder'])) {
373 $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
374 $admin_url .= $last_status;
375 ?>
376 <script>
377 window.location = '<?php echo $admin_url ?>';
378 </script>
379 <?php
380 exit;
381 }
382 } else {
383 $post_type = self::get_custom_post_type($typenow);
384 $admin_url = admin_url("edit.php?post_type=" . $typenow);
385 $admin_url .= "&{$post_type}=";
386 if (!isset($_REQUEST[$post_type])) {
387 $admin_url .= $last_status;
388 ?>
389 <script>
390 window.location = '<?php echo $admin_url ?>';
391 </script>
392 <?php
393 exit;
394 }
395 }
396 }
397 }
398
399 $default_folders = get_option('default_folders');
400 $default_folders = (empty($default_folders) || !is_array($default_folders))?array():$default_folders;
401
402 $status = 1;
403 if(isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
404 $type = self::get_custom_post_type($typenow);
405 if($default_folders[$typenow] != -1) {
406 $term = get_term_by('slug', $default_folders[$typenow], $type);
407 if (empty($term) || !is_object($term)) {
408 $status = 0;
409 }
410 }
411 } else {
412 $status = 0;
413 }
414 if($status) {
415 if ($typenow == "attachment") {
416 $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
417 if (!isset($_REQUEST['media_folder'])) {
418 if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
419 $admin_url .= $default_folders[$typenow];
420 ?>
421 <script>
422 window.location = '<?php echo $admin_url ?>';
423 </script>
424 <?php
425 exit;
426 }
427 }
428 } else {
429 $admin_url = admin_url("edit.php?post_type=" . $typenow);
430 if (isset($_GET['s']) && !empty($_GET['s'])) {
431 $admin_url .= "&s=" . $_GET['s'];
432 }
433 $post_type = self::get_custom_post_type($typenow);
434 $admin_url .= "&{$post_type}=";
435 if (!isset($_REQUEST[$post_type])) {
436 if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
437 $admin_url .= $default_folders[$typenow];
438 ?>
439 <script>
440 window.location = '<?php echo $admin_url ?>';
441 </script>
442 <?php
443 exit;
444 }
445 }
446 }
447 }
448 }
449 }
450
451 public function folder_update_status() {
452 if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'folder_update_status')) {
453 $status = filter_input(INPUT_POST, 'status', FILTER_SANITIZE_STRING);
454 $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING);
455 update_option("folder_update_message", 2);
456 if($status == 1) {
457 $url = 'https://go.premio.io/api/update.php?email='.$email.'&plugin=folders';
458 $handle = curl_init();
459 curl_setopt($handle, CURLOPT_URL, $url);
460 curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
461 $response = curl_exec($handle);
462 curl_close($handle);
463 }
464 }
465 echo "1";
466 die;
467 }
468
469 public function add_attachment_category($post_ID)
470 {
471 if(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
472 $folder_id = isset($_REQUEST["folder_for_media"]) ? $_REQUEST["folder_for_media"] : null;
473 if ($folder_id !== null) {
474 $folder_id = (int)$folder_id;
475 $folder_id = self::sanitize_options($folder_id, "int");
476 if ($folder_id > 0) {
477 $post_type = self::get_custom_post_type("attachment");
478 $term = get_term($folder_id);
479 if(!empty($term) && isset($term->slug)) {
480 wp_set_object_terms($post_ID, $term->slug, $post_type );
481 }
482 }
483 }
484 }
485 }
486
487 public function show_dropdown_on_media_screen() {
488 if(self::is_for_this_post_type('attachment')) {
489 $post_type = self::get_custom_post_type('attachment');
490 global $typenow, $current_screen;
491 /* Free/Pro Class name change */
492 if(!class_exists('WCP_Tree')) {
493 $files = array(
494 'WCP_Tree' => WCP_DS . "includes" . WCP_DS . "tree.class.php"
495 );
496
497 foreach ($files as $file) {
498 if (file_exists(dirname(dirname(__FILE__)) . $file)) {
499 include_once dirname(dirname(__FILE__)) . $file;
500 }
501 }
502 }
503 /* Free/Pro Class name change */
504 $options = WCP_Tree::get_folder_option_data($post_type);?>
505 <p class="attachments-category"><?php esc_html_e("Select a folder (Optional)", WCP_FOLDER) ?></p>
506 <p class="attachments-category"><?php esc_html_e("First select the folder, and the upload the files", WCP_FOLDER) ?><br/></p>
507 <p>
508 <?php
509 $request = $_SERVER['REQUEST_URI'];
510 $request = strpos($request, "post.php");
511 ?>
512 <select name="folder_for_media" class="folder_for_media">
513 <option value="-1">- <?php esc_html_e('Unassigned', WCP_FOLDER) ?></option>
514 <?php echo $options ?>
515 <?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')) {?>
516 <option value="add-folder"><?php esc_html_e('+ Create a New Folder', WCP_FOLDER) ?></option>
517 <?php } ?>
518 </select>
519 </p>
520 <?php
521 }
522 }
523
524 public function wcp_hide_folders()
525 {
526 $response = array();
527 $response['status'] = 0;
528 $response['error'] = 0;
529 $response['data'] = array();
530 $response['message'] = "";
531 $postData = filter_input_array(INPUT_POST);
532 $errorCounter = 0;
533
534 if (!isset($postData['status']) || empty($postData['status'])) {
535 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
536 $errorCounter++;
537 } else if (!isset($postData['type']) || empty($postData['type'])) {
538 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
539 $errorCounter++;
540 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
541 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
542 $errorCounter++;
543 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
544 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
545 $errorCounter++;
546 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
547 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
548 $errorCounter++;
549 } else {
550 $type = self::sanitize_options($postData['type']);
551 $nonce = self::sanitize_options($postData['nonce']);
552 if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
553 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
554 $errorCounter++;
555 }
556 }
557 if ($errorCounter == 0) {
558 $type = self::sanitize_options($postData['type']);
559 $status = self::sanitize_options($postData['status']);
560 $optionName = "wcp_folder_display_status_" . $type;
561 update_option($optionName, $status);
562 $response['status'] = 1;
563 }
564 echo json_encode($response);
565 wp_die();
566 }
567
568 public function wcp_change_folder_display_status()
569 {
570 $response = array();
571 $response['status'] = 0;
572 $response['error'] = 0;
573 $response['data'] = array();
574 $response['message'] = "";
575 $postData = filter_input_array(INPUT_POST);
576 $errorCounter = 0;
577 if (!isset($postData['status']) || empty($postData['status'])) {
578 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
579 $errorCounter++;
580 } else if (!isset($postData['type']) || empty($postData['type'])) {
581 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
582 $errorCounter++;
583 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
584 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
585 $errorCounter++;
586 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
587 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
588 $errorCounter++;
589 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
590 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
591 $errorCounter++;
592 } else {
593 $type = self::sanitize_options($postData['type']);
594 $nonce = self::sanitize_options($postData['nonce']);
595 if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
596 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
597 $errorCounter++;
598 }
599 }
600 if ($errorCounter == 0) {
601 $type = self::sanitize_options($postData['type']);
602 $width = self::sanitize_options($postData['status']);
603 $optionName = "wcp_dynamic_display_status_" . $type;
604 update_option($optionName, $width);
605 $response['status'] = 1;
606 }
607 echo json_encode($response);
608 wp_die();
609 }
610
611 public function wcp_remove_post_folder() {
612 $response = array();
613 $response['status'] = 0;
614 $response['error'] = 0;
615 $response['data'] = array();
616 $response['message'] = "";
617 $postData = filter_input_array(INPUT_POST);
618 $errorCounter = 0;
619 if (!isset($postData['post_id']) || empty($postData['post_id'])) {
620 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
621 $errorCounter++;
622 } else if (!isset($postData['type']) || empty($postData['type'])) {
623 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
624 $errorCounter++;
625 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
626 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
627 $errorCounter++;
628 } else if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['type'])) {
629 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
630 $errorCounter++;
631 } else if(!current_user_can("manage_categories")) {
632 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
633 $errorCounter++;
634 }
635 if ($errorCounter == 0) {
636 $type = self::sanitize_options($postData['type']);
637 $post_id = self::sanitize_options($postData['post_id']);
638
639 $post_id = explode(",", $post_id);
640
641 $taxonomy = self::get_custom_post_type($type);
642
643 foreach($post_id as $id) {
644 if(!empty($id) && is_numeric($id) && $id > 0) {
645 wp_delete_object_term_relationships($id, $taxonomy);
646 }
647 }
648
649 $response['status'] = 1;
650 }
651 echo json_encode($response);
652 wp_die();
653 }
654
655 public function filter_record_list($query) {
656 global $typenow;
657
658 if($typenow == "attachment") {
659 return;
660 }
661
662 if(!self::is_for_this_post_type($typenow)) {
663 return $query;
664 }
665
666 $taxonomy = self::get_custom_post_type($typenow);
667
668 if ( ! isset( $query->query['post_type'] ) ) {
669 return $query;
670 }
671
672 if ( ! isset( $_REQUEST[$taxonomy] ) ) {
673 return $query;
674 }
675
676 $term = sanitize_text_field( $_REQUEST[$taxonomy] );
677 if ( $term != "-1" ) {
678 return $query;
679 }
680
681 unset( $query->query_vars[$taxonomy] );
682
683 $tax_query = array(
684 'taxonomy' => $taxonomy,
685 'operator' => 'NOT EXISTS',
686 );
687
688 $query->set( 'tax_query', array( $tax_query ) );
689 $query->tax_query = new WP_Tax_Query( array( $tax_query ) );
690
691 return $query;
692 }
693
694 public function wcp_get_default_list() {
695
696 $postData = filter_input_array(INPUT_POST);
697
698 $post_type = $postData['type'];
699
700 $ttpsts = $this->get_ttlpst($post_type);
701
702 $empty_items = self::get_tempt_posts($post_type);
703
704 $post_type = self::get_custom_post_type($post_type);
705
706 $taxonomies = self::get_terms_hierarchical($post_type);
707
708 $response = array(
709 'status' => 1,
710 'total_items' => $ttpsts,
711 'taxonomies' => $taxonomies,
712 'empty_items' => $empty_items
713 );
714 echo json_encode($response);
715 wp_die();
716 }
717
718 function get_folders_default_list() {
719 $postData = filter_input_array(INPUT_POST);
720
721 $post_type = $postData['type'];
722
723 $ttpsts = $this->get_ttlpst($post_type);
724
725 $empty_items = self::get_tempt_posts($post_type);
726
727 $post_type = self::get_custom_post_type($post_type);
728
729 $taxonomies = self::get_terms_hierarchical($post_type);
730
731 $response = array(
732 'status' => 1,
733 'total_items' => $ttpsts,
734 'empty_items' => $empty_items,
735 'taxonomies' => $taxonomies
736 );
737 echo json_encode($response);
738 die;
739
740 }
741
742 function save_media_terms( $post_id ) {
743 if ( wp_is_post_revision( $post_id ) ) {
744 return;
745 }
746 $post = get_post($post_id);
747 if($post->post_type !== 'attachment') {
748 return;
749 }
750 $post_type = self::get_custom_post_type('attachment');
751 $selected_folder = get_option("selected_{$post_type}_folder");
752 if($selected_folder != null && !empty($selected_folder)) {
753 $terms = get_term($selected_folder);
754 if(!empty($terms) && isset($terms->term_id)) {
755 wp_set_post_terms($post_id, $terms->term_id, $post_type, false);
756 }
757 }
758 }
759
760 public function filter_attachments_grid( $args ) {
761 $taxonomy = 'media_folder';
762 if ( ! isset( $args[ $taxonomy ] ) ) {
763 return $args;
764 }
765 $term = sanitize_text_field( $args[ $taxonomy ] );
766 if ( $term != "-1" ) {
767 return $args;
768 }
769 unset( $args[ $taxonomy ] );
770 $args['tax_query'] = array(
771 array(
772 'taxonomy' => $taxonomy,
773 'operator' => 'NOT EXISTS',
774 ),
775 );
776 $args = apply_filters( 'media_library_organizer_media_filter_attachments_grid', $args );
777 return $args;
778 }
779
780 public function get_tempt_posts($post_type = "")
781 {
782 global $wpdb;
783
784 $post_table = $wpdb->prefix."posts";
785 $term_table = $wpdb->prefix."term_relationships";
786 $term_taxonomy_table = $wpdb->prefix."term_taxonomy";
787 $taxonomy = self::get_custom_post_type($post_type);
788 $tlrcds = null;
789 if(has_filter("premio_folder_un_categorized_items")) {
790 $tlrcds = apply_filters("premio_folder_un_categorized_items", $post_type, $taxonomy);
791 }
792 if($tlrcds === null) {
793 if ($post_type != "attachment") {
794 $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND (
795 NOT EXISTS (
796 SELECT 1
797 FROM {$term_table}
798 INNER JOIN {$term_taxonomy_table}
799 ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id
800 WHERE {$term_taxonomy_table}.taxonomy = '%s'
801 AND {$term_table}.object_id = {$post_table}.ID
802 )
803 ) 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'))";
804 } else {
805 $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND (
806 NOT EXISTS (
807 SELECT 1
808 FROM {$term_table}
809 INNER JOIN {$term_taxonomy_table}
810 ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id
811 WHERE {$term_taxonomy_table}.taxonomy = '%s'
812 AND {$term_table}.object_id = {$post_table}.ID
813 )
814 ) AND {$post_table}.post_type = '%s' AND {$post_table}.post_status = 'inherit'";
815 }
816
817 $query = $wpdb->prepare($query, $taxonomy, $post_type);
818
819 $tlrcds = $wpdb->get_var($query);
820 }
821
822 if(!empty($tlrcds)) {
823 return $tlrcds;
824 } else {
825 return 0;
826 }
827 }
828
829 public function output_backbone_view_filters() {
830
831 global $typenow, $current_screen;
832 $isAjax = (defined('DOING_AJAX') && DOING_AJAX)?1:0;
833 $options = get_option('folders_settings');
834 $options = (empty($options) || !is_array($options))?array():$options;
835 $last_status = get_option("last_folder_status_for".$typenow);
836 if(!$isAjax && (in_array($typenow, $options) || !empty($last_status)) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) {
837
838 $default_folders = get_option('default_folders');
839 $default_folders = (empty($default_folders) || !is_array($default_folders))?array():$default_folders;
840
841 if(!empty($last_status)) {
842 $status = 1;
843 if($last_status != "-1" && $last_status != "all") {
844 $type = self::get_custom_post_type($typenow);
845 $term = get_term_by('slug', $last_status, $type);
846 if (empty($term) || !is_object($term)) {
847 $status = 0;
848 }
849 }
850 delete_option("last_folder_status_for".$typenow);
851 if($last_status == "all") {
852 $last_status = "";
853 }
854 if($status) {
855 if ($typenow == "attachment") {
856 if (!isset($_REQUEST['media_folder'])) {
857 $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
858 $admin_url .= $last_status;
859 ?>
860 <script>
861 window.location = '<?php echo $admin_url ?>';
862 </script>
863 <?php
864 exit;
865 }
866 }
867 }
868 }
869
870 $status = 1;
871 if(isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
872 $type = self::get_custom_post_type($typenow);
873 if($default_folders[$typenow] != -1) {
874 $term = get_term_by('slug', $default_folders[$typenow], $type);
875 if (empty($term) || !is_object($term)) {
876 $status = 0;
877 }
878 }
879 } else {
880 $status = 0;
881 }
882 if($status) {
883 if ($typenow == "attachment") {
884 $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
885 if (!isset($_REQUEST['media_folder'])) {
886 if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) {
887 $admin_url .= $default_folders[$typenow];
888 ?>
889 <script>
890 window.location = '<?php echo $admin_url ?>';
891 </script>
892 <?php
893 exit;
894 }
895 }
896 }
897 }
898 }
899
900 if(!(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media'))) {
901 return;
902 }
903
904 if ($typenow == "attachment" || !is_admin()) {
905 /* Free/Pro URL Change */
906 global $typenow;
907 $is_active = 1;
908 $folders = -1;
909 if (!self::check_has_valid_key()) {
910 $is_active = 0;
911 $folders = self::ttl_fldrs();
912 }
913
914 /* Free/Pro URL Change */
915 wp_enqueue_script( 'folders-media', WCP_FOLDER_URL.'assets/js/media.js', array( 'media-editor', 'media-views' ), WCP_FOLDER_VERSION, true );
916 wp_localize_script( 'folders-media', 'folders_media_options', array(
917 'terms' => self::get_terms_hierarchical('media_folder'),
918 'taxonomy' => get_taxonomy('media_folder'),
919 'ajax_url' => admin_url("admin-ajax.php"),
920 'activate_url' => admin_url("admin.php?page=wcp_folders_register"),
921 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
922 'is_key_active' => $is_active,
923 'folders' => $folders,
924 ));
925 /* Free/Pro URL Change */
926 wp_enqueue_style( 'folders-media', WCP_FOLDER_URL . 'assets/css/media.css' , array(), WCP_FOLDER_VERSION);
927 } else if(is_admin() && !self::is_active_for_screen()) {
928 global $current_screen;
929 if(isset($current_screen->base) && $current_screen->base == "post") {
930 /* Free/Pro URL Change */
931 $is_active = 1;
932 $folders = -1;
933 if (!self::check_has_valid_key()) {
934 $is_active = 0;
935 $folders = self::ttl_fldrs();
936 }
937
938 /* Free/Pro URL Change */
939
940 $is_rtl = 0;
941 if (function_exists('is_rtl') && is_rtl()) {
942 $is_rtl = 1;
943 }
944 $can_manage_folder = current_user_can("manage_categories") ? 1 : 0;
945 $width = 275;
946 $taxonomy_status = 0;
947 $selected_taxonomy = "";
948 $show_in_page = false;
949 $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
950
951 wp_enqueue_script('folders-livequery', plugin_dir_url(dirname(__FILE__)) . 'assets/js/livequery.min.js', array(), WCP_FOLDER_VERSION);
952 wp_enqueue_script('folders-media', WCP_FOLDER_URL . 'assets/js/page-post-media.min.js', array('media-editor', 'media-views', 'jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION, true);
953 wp_localize_script('folders-media', 'folders_media_options', array(
954 'terms' => self::get_terms_hierarchical('media_folder'),
955 'taxonomy' => get_taxonomy('media_folder'),
956 'ajax_url' => admin_url("admin-ajax.php"),
957 'media_page_url' => admin_url("upload.php"),
958 'activate_url' => admin_url("admin.php?page=wcp_folders_register"),
959 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
960 'is_key_active' => $is_active,
961 'folders' => $folders,
962 'upgrade_url' => admin_url('admin.php?page=wcp_folders_upgrade'),
963 'post_type' => 'attachment',
964 'page_url' => $admin_url,
965 'current_url' => "",
966 'ajax_image' => plugin_dir_url(dirname(__FILE__)) . "assets/images/ajax-loader.gif",
967 'register_url' => "",
968 'isRTL' => $is_rtl,
969 'can_manage_folder' => $can_manage_folder,
970 'folder_width' => $width,
971 'taxonomy_status' => $taxonomy_status,
972 'selected_taxonomy' => $selected_taxonomy,
973 'show_in_page' => $show_in_page,
974 'svg_file' => WCP_FOLDER_URL . 'assets/images/pin.png',
975 ));
976 /* Free/Pro URL Change */
977 wp_enqueue_style('folders-media', WCP_FOLDER_URL . 'assets/css/page-post-media.min.css', array(), WCP_FOLDER_VERSION);
978 wp_enqueue_style('folder-icon', WCP_FOLDER_URL . 'assets/css/folder-icon.css', array(), WCP_FOLDER_VERSION);
979 $width = 275;
980 $width = $width - 40;
981 $string = "";
982 $css_text = "";
983 for ($i = 0; $i <= 15; $i++) {
984 $string .= " .space > .route >";
985 $new_width = $width - (13 + (20 * $i));
986 $css_text .= "#custom-menu > {$string} .title { width: {$new_width}px !important; } ";
987 $css_text .= "#custom-menu > {$string} .dynamic-menu { left: " . ($new_width - 190) . "px !important; } ";
988 }
989 $css_text .= '.ui-state-highlight { background: transparent; border: dashed 1px #0073AA; width:150px; height: 25px !important; }';
990 $customize_folders = get_option('customize_folders');
991 if (isset($customize_folders['new_folder_color']) && !empty($customize_folders['new_folder_color'])) {
992 $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']) . "}";
993 $css_text .= ".wcp-hide-show-buttons .toggle-buttons {background-color: " . esc_attr($customize_folders['new_folder_color']) . "; }";
994 $css_text .= ".folders-toggle-button span { background-color: " . esc_attr($customize_folders['new_folder_color']) . "; }";
995 $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}";
996 }
997 if (isset($customize_folders['folder_bg_color']) && !empty($customize_folders['folder_bg_color'])) {
998 $rgbColor = self::hexToRgb($customize_folders['folder_bg_color']);
999 $css_text .= ".orange-bg > span ,.wcp-container .route.active-item > h3.title, .header-posts a.active-item, .un-categorised-items.active-item { background-color: " . esc_attr($customize_folders['folder_bg_color']) . " !important; color: #ffffff; }";
1000 $css_text .= "body:not(.no-hover-css) .wcp-container .route .title:hover, .header-posts a:hover, .un-categorised-items.active-item, .un-categorised-items:hover {background: rgba(" . esc_attr($rgbColor['r'] . "," . $rgbColor['g'] . "," . $rgbColor['b'] . ", 0.08") . ");}";
1001 $css_text .= ".wcp-drop-hover {background-color: " . esc_attr($customize_folders['folder_bg_color']) . " !important; color: #ffffff; }";
1002 $css_text .= "#custom-menu .route .nav-icon .wcp-icon {color: " . esc_attr($customize_folders['folder_bg_color']) . " !important;}";
1003 $css_text .= ".ui-state-highlight { border-color: " . esc_attr($customize_folders['folder_bg_color']) . " !important;background: rgba(" . esc_attr($rgbColor['r'] . "," . $rgbColor['g'] . "," . $rgbColor['b'] . ", 0.08") . "}";
1004 }
1005 if (isset($customize_folders['bulk_organize_button_color']) && !empty($customize_folders['bulk_organize_button_color'])) {
1006 $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']) . "; }";
1007 $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']) . "; }";
1008 }
1009 $font_family = "";
1010 if (isset($customize_folders['folder_font']) && !empty($customize_folders['folder_font'])) {
1011 $folder_fonts = self::get_font_list();
1012 $font_family = $customize_folders['folder_font'];
1013 if (isset($folder_fonts[$font_family])) {
1014 $css_text .= ".wcp-container, .folder-popup-form { font-family: " . esc_attr($font_family) . " !important; }";
1015 }
1016 if ($folder_fonts[$font_family] == "Default") {
1017 $font_family = "";
1018 }
1019 }
1020 if (isset($customize_folders['folder_size']) && !empty($customize_folders['folder_size'])) {
1021 $css_text .= ".wcp-container .route span.title-text, .header-posts a, .un-categorised-items a { font-size: " . esc_attr($customize_folders['folder_size']) . "px; }";
1022 }
1023 if (!empty($font_family)) {
1024 wp_enqueue_style('custom-google-fonts', 'https://fonts.googleapis.com/css?family=' . urlencode($font_family), false);
1025 }
1026 wp_add_inline_style('folders-media', $css_text);
1027 }
1028 }
1029 }
1030
1031 public function get_terms_hierarchical( $taxonomy ) {
1032 // $terms = get_terms( array(
1033 // 'taxonomy' => $taxonomy,
1034 // 'hide_empty' => false,
1035 // 'parent' => 0,
1036 // 'orderby' => 'meta_value_num',
1037 // 'order' => 'ASC',
1038 // 'update_count_callback' => '_update_generic_term_count',
1039 // 'meta_query' => [[
1040 // 'key' => 'wcp_custom_order',
1041 // 'type' => 'NUMERIC',
1042 // ]]
1043 // ) );
1044 //
1045 // if ( empty( $terms ) ) {
1046 // return false;
1047 // }
1048 //
1049 // $hierarchy = _get_term_hierarchy( $taxonomy );
1050 //
1051 // $hierarchical_terms = array();
1052 // if(!empty($terms)) {
1053 // foreach ($terms as $term) {
1054 // if(isset($term->term_id)) {
1055 // $hierarchical_terms[] = $term;
1056 // $hierarchical_terms = self::add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $term->term_id, 1);
1057 // }
1058 // }
1059 // }
1060 //
1061 // return $hierarchical_terms;
1062 $terms = get_terms( array(
1063 'taxonomy' => $taxonomy,
1064 'hide_empty' => false,
1065 'parent' => 0,
1066 'orderby' => 'meta_value_num',
1067 'order' => 'ASC',
1068 'hierarchical' => false,
1069 'update_count_callback' => '_update_generic_term_count',
1070 'meta_query' => [[
1071 'key' => 'wcp_custom_order',
1072 'type' => 'NUMERIC',
1073 ]]
1074 ));
1075 $hierarchical_terms = array();
1076 if(!empty($terms)) {
1077 foreach ($terms as $term) {
1078 if(!empty($term) && isset($term->term_id)) {
1079 $term->term_name = $term->name;
1080 $hierarchical_terms[] = $term;
1081 $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, "-");
1082 }
1083 }
1084 }
1085 return $hierarchical_terms;
1086 }
1087
1088 public static function get_child_terms($taxonomy, $hierarchical_terms, $term_id, $separator = "-") {
1089 $terms = get_terms( array(
1090 'taxonomy' => $taxonomy,
1091 'hide_empty' => false,
1092 'parent' => $term_id,
1093 'orderby' => 'meta_value_num',
1094 'order' => 'ASC',
1095 'hierarchical' => false,
1096 'update_count_callback' => '_update_generic_term_count',
1097 'meta_query' => [[
1098 'key' => 'wcp_custom_order',
1099 'type' => 'NUMERIC',
1100 ]]
1101 ));
1102 if(!empty($terms)) {
1103 foreach ($terms as $term) {
1104 if(isset($term->name)) {
1105 $term->name = $separator . " " . $term->name;
1106 $term->term_name = trim($term->name, "-");
1107 $hierarchical_terms[] = $term;
1108 $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, $separator . "-");
1109 }
1110 }
1111 }
1112
1113 return $hierarchical_terms;
1114 }
1115
1116 private function add_child_terms_recursive( $taxonomy, $hierarchical_terms, $hierarchy, $current_term_id, $current_depth ) {
1117
1118 if ( ! isset( $hierarchy[ $current_term_id ] ) ) {
1119 return $hierarchical_terms;
1120 }
1121
1122 foreach ( $hierarchy[ $current_term_id ] as $child_term_id ) {
1123
1124 $child_term = get_term( $child_term_id, $taxonomy );
1125
1126 $child_term->name = str_pad( '', $current_depth, '-', STR_PAD_LEFT ) . ' ' . $child_term->name;
1127
1128 $hierarchical_terms[] = $child_term;
1129
1130 $hierarchical_terms = self::add_child_terms_recursive( $taxonomy, $hierarchical_terms, $hierarchy, $child_term_id, ( $current_depth + 1 ) );
1131 }
1132
1133 return $hierarchical_terms;
1134 }
1135
1136 public function filter_attachments_list( $query ) {
1137
1138 if ( ! isset( $query->query['post_type'] ) ) {
1139 return $query;
1140 }
1141
1142 if ( is_array( $query->query['post_type'] ) && ! in_array( 'attachment', $query->query['post_type'] ) ) {
1143 return $query;
1144 }
1145 if ( ! is_array( $query->query['post_type'] ) && strpos( $query->query['post_type'], 'attachment' ) === false ) {
1146 return $query;
1147 }
1148
1149 if ( ! isset( $_REQUEST['media_folder'] ) ) {
1150 return $query;
1151 }
1152
1153 $term = sanitize_text_field(wp_unslash($_REQUEST['media_folder']));
1154 if ( $term != "-1" ) {
1155 return $query;
1156 }
1157
1158 unset( $query->query_vars['media_folder'] );
1159
1160 $tax_query = array(
1161 'taxonomy' => 'media_folder',
1162 'operator' => 'NOT EXISTS',
1163 );
1164
1165 $query->set( 'tax_query', array( $tax_query ) );
1166 $query->tax_query = new WP_Tax_Query( array( $tax_query ) );
1167
1168 $query = apply_filters( 'media_library_organizer_media_filter_attachments', $query, $_REQUEST );
1169
1170 return $query;
1171
1172 }
1173
1174 public function output_list_table_filters( $post_type, $view_name )
1175 {
1176 if ($post_type != 'attachment') {
1177 return;
1178 }
1179
1180 if ($view_name != 'bar') {
1181 return;
1182 }
1183
1184 $current_term = false;
1185 if ( isset( $_REQUEST['media_folder'] ) ) {
1186 $current_term = sanitize_text_field($_REQUEST['media_folder']);
1187 }
1188
1189 wp_dropdown_categories( array(
1190 'show_option_all' => esc_attr__( 'All Folders', WCP_FOLDER),
1191 'show_option_none' => esc_attr__( '(Unassigned)', WCP_FOLDER),
1192 'option_none_value' => -1,
1193 'orderby' => 'meta_value_num',
1194 'order' => 'ASC',
1195 'show_count' => true,
1196 'hide_empty' => false,
1197 'update_count_callback' => '_update_generic_term_count',
1198 'echo' => true,
1199 'selected' => $current_term,
1200 'hierarchical' => true,
1201 'name' => 'media_folder',
1202 'id' => '',
1203 'class' => '',
1204 'taxonomy' => 'media_folder',
1205 'value_field' => 'slug',
1206 'meta_query' => [[
1207 'key' => 'wcp_custom_order',
1208 'type' => 'NUMERIC',
1209 ]]
1210 ) );
1211
1212 }
1213
1214
1215 function new_to_auto_draft($post) {
1216
1217 $post_type = $post->post_type;
1218
1219 if(self::is_for_this_post_type($post_type) && !isset($_REQUEST["folder_for_media"])) {
1220
1221 $post_type = self::get_custom_post_type($post_type);
1222 $selected_folder = get_option("selected_{$post_type}_folder");
1223
1224 if($selected_folder != null && !empty($selected_folder)) {
1225 $terms = get_term($selected_folder);
1226 if(!empty($terms) && isset($terms->slug)) {
1227 wp_set_object_terms($post->ID, $terms->slug, $post_type );
1228 }
1229
1230 }
1231 }
1232 }
1233
1234 public function wcp_folder_send_message_to_owner() {
1235 if (current_user_can('manage_options')) {
1236 $response = array();
1237 $response['status'] = 0;
1238 $response['error'] = 0;
1239 $response['errors'] = array();
1240 $response['message'] = "";
1241 $errorArray = [];
1242 $errorMessage = esc_attr__("%s is required", WCP_FOLDER);
1243 $postData = filter_input_array(INPUT_POST);
1244 if (!isset($postData['textarea_text']) || trim($postData['textarea_text']) == "") {
1245 $error = array(
1246 "key" => "textarea_text",
1247 "message" => esc_attr__("Please enter your message", WCP_FOLDER)
1248 );
1249 $errorArray[] = $error;
1250 }
1251 if (!isset($postData['user_email']) || trim($postData['user_email']) == "") {
1252 $error = array(
1253 "key" => "user_email",
1254 "message" => sprintf($errorMessage, __("Email", WCP_FOLDER))
1255 );
1256 $errorArray[] = $error;
1257 } else if (!filter_var($postData['user_email'], FILTER_VALIDATE_EMAIL)) {
1258 $error = array(
1259 'key' => "user_email",
1260 "message" => "Email is not valid"
1261 );
1262 $errorArray[] = $error;
1263 }
1264 if (empty($errorArray)) {
1265 if (!isset($postData['folder_help_nonce']) || trim($postData['folder_help_nonce']) == "") {
1266 $error = array(
1267 "key" => "nonce",
1268 "message" => esc_attr__("Your request is not valid", WCP_FOLDER)
1269 );
1270 $errorArray[] = $error;
1271 } else {
1272 if (!wp_verify_nonce($postData['folder_help_nonce'], 'wcp_folder_help_nonce')) {
1273 $error = array(
1274 "key" => "nonce",
1275 "message" => esc_attr__("Your request is not valid", WCP_FOLDER)
1276 );
1277 $errorArray[] = $error;
1278 }
1279 }
1280 }
1281 if (empty($errorArray)) {
1282 global $current_user;
1283 $text_message = self::sanitize_options($postData['textarea_text']);
1284 $email = self::sanitize_options($postData['user_email'], "email");
1285 $domain = site_url();
1286 $user_name = $current_user->first_name . " " . $current_user->last_name;
1287 $subject = "Folder request: " . $domain;
1288 $headers = "MIME-Version: 1.0\r\n";
1289 $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
1290 $headers .= 'From: ' . $user_name . ' <' . $email . '>' . PHP_EOL;
1291 $headers .= 'Reply-To: ' . $user_name . ' <' . $email . '>' . PHP_EOL;
1292 $headers .= 'X-Mailer: PHP/' . phpversion();
1293 ob_start();
1294 ?>
1295 <table border="0" cellspacing="0" cellpadding="5">
1296 <tr>
1297 <th>Domain</th>
1298 <td><?php echo esc_attr($domain) ?></td>
1299 </tr>
1300 <tr>
1301 <th>Email</th>
1302 <td><?php echo esc_attr($email) ?></td>
1303 </tr>
1304 <tr>
1305 <th>Message</th>
1306 <td><?php echo nl2br($text_message) ?></td>
1307 </tr>
1308 </table>
1309 <?php
1310 $message = ob_get_clean();
1311 $email_id = "gal@premio.io, karina@premio.io";
1312 $status = wp_mail($email_id, $subject, $message, $headers);
1313 if ($status) {
1314 $response['status'] = 1;
1315 } else {
1316 $response['status'] = 0;
1317 $response['message'] = "Not able to send mail";
1318 }
1319 } else {
1320 $response['error'] = 1;
1321 $response['errors'] = $errorArray;
1322 }
1323 echo json_encode($response);
1324 }
1325 }
1326
1327 public function folder_plugin_deactivate() {
1328 if (current_user_can('manage_options')) {
1329 global $current_user;
1330 $postData = filter_input_array(INPUT_POST);
1331 $errorCounter = 0;
1332 $response = array();
1333 $response['status'] = 0;
1334 $response['message'] = "";
1335 $response['valid'] = 1;
1336 if(!isset($postData['reason']) || empty($postData['reason'])) {
1337 $errorCounter++;
1338 $response['message'] = "Please provide reason";
1339 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1340 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1341 $errorCounter++;
1342 $response['valid'] = 0;
1343 } else {
1344 $nonce = self::sanitize_options($postData['nonce']);
1345 if(!wp_verify_nonce($nonce, 'wcp_folder_deactivate_nonce')) {
1346 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1347 $errorCounter++;
1348 $response['valid'] = 0;
1349 }
1350 }
1351 if($errorCounter == 0) {
1352 $reason = $postData['reason'];
1353 $email = "none@none.none";
1354 if (isset($postData['email_id']) && !empty($postData['email_id']) && filter_var($postData['email_id'], FILTER_VALIDATE_EMAIL)) {
1355 $email = $postData['email_id'];
1356 }
1357 $domain = site_url();
1358 $user_name = $current_user->first_name." ".$current_user->last_name;
1359 $subject = "Folders was removed from {$domain}";
1360 $headers = "MIME-Version: 1.0\r\n";
1361 $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
1362 $headers .= 'From: '.$user_name.' <'.$email.'>'.PHP_EOL ;
1363 $headers .= 'Reply-To: '.$user_name.' <'.$email.'>'.PHP_EOL ;
1364 $headers .= 'X-Mailer: PHP/' . phpversion();
1365 ob_start();
1366 ?>
1367 <table border="0" cellspacing="0" cellpadding="5">
1368 <tr>
1369 <th>Plugin</th>
1370 <td>Folders</td>
1371 </tr>
1372 <tr>
1373 <th>Plugin Version</th>
1374 <!-- Free Pro Version Change -->
1375 <td><?php echo esc_attr(WCP_FOLDER_VERSION) ?></td>
1376 </tr>
1377 <tr>
1378 <th>Domain</th>
1379 <td><?php echo esc_attr($domain) ?></td>
1380 </tr>
1381 <tr>
1382 <th>Email</th>
1383 <td><?php echo esc_attr($email) ?></td>
1384 </tr>
1385 <tr>
1386 <th>Comment</th>
1387 <td><?php echo nl2br($reason) ?></td>
1388 </tr>
1389 <tr>
1390 <th>WordPress Version</th>
1391 <td><?php echo esc_attr(get_bloginfo('version')) ?></td>
1392 </tr>
1393 <tr>
1394 <th>PHP Version</th>
1395 <td><?php echo esc_attr(PHP_VERSION) ?></td>
1396 </tr>
1397 </table>
1398 <?php
1399 $content = ob_get_clean();
1400 $email_id = "gal@premio.io, karina@premio.io";
1401 wp_mail($email_id, $subject, $content, $headers);
1402 $response['status'] = 1;
1403 }
1404 echo json_encode($response);
1405 wp_die();
1406 }
1407 }
1408
1409 public static function ttl_fldrs() {
1410 $post_types = get_option(WCP_FOLDER_VAR);
1411 $post_types = is_array($post_types) ? $post_types : array();
1412 $total = 0;
1413 foreach ($post_types as $post_type) {
1414 $post_type = self::get_custom_post_type($post_type);
1415 $total += wp_count_terms($post_type);
1416 }
1417 return $total;
1418 }
1419
1420 public function wcp_remove_post_item()
1421 {
1422 $response = array();
1423 $response['status'] = 0;
1424 $response['error'] = 0;
1425 $response['data'] = array();
1426 $response['message'] = "";
1427 $postData = filter_input_array(INPUT_POST);
1428 if (isset($postData['post_id']) && !empty($postData['post_id'])) {
1429 wp_delete_post($postData['post_id']);
1430 $response['status'] = 1;
1431 }
1432 echo json_encode($response);
1433 wp_die();
1434 }
1435
1436 public function wcp_change_all_status()
1437 {
1438 $response = array();
1439 $response['status'] = 0;
1440 $response['error'] = 0;
1441 $response['data'] = array();
1442 $response['message'] = "";
1443 $postData = filter_input_array(INPUT_POST);
1444 $errorCounter = 0;
1445 if (!isset($postData['type']) || empty($postData['type'])) {
1446 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1447 $errorCounter++;
1448 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1449 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1450 $errorCounter++;
1451 } else if (!current_user_can("manage_categories") || ($postData['type'] == "page" && !current_user_can("edit_pages"))) {
1452 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
1453 $errorCounter++;
1454 } else if (!current_user_can("manage_categories") || ($postData['type'] != "page" && !current_user_can("edit_posts"))) {
1455 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
1456 $errorCounter++;
1457 } else {
1458 $type = self::sanitize_options($postData['type']);
1459 $nonce = self::sanitize_options($postData['nonce']);
1460 if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
1461 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1462 $errorCounter++;
1463 }
1464 }
1465 if ($errorCounter == 0) {
1466 if (isset($postData['folders']) || !empty($postData['folders'])) {
1467 $status = isset($postData['status']) ? $postData['status'] : 0;
1468 $status = self::sanitize_options($status);
1469 $folders = self::sanitize_options($postData['folders']);
1470 $folders = trim($folders, ",");
1471 $folders = explode(",", $folders);
1472 foreach ($folders as $folder) {
1473 update_term_meta($folder, "is_active", $status);
1474 }
1475 }
1476 $response['status'] = 1;
1477 }
1478 echo json_encode($response);
1479 wp_die();
1480 }
1481
1482 public function wcp_change_post_width()
1483 {
1484 $response = array();
1485 $response['status'] = 0;
1486 $response['error'] = 0;
1487 $response['data'] = array();
1488 $response['message'] = "";
1489 $postData = filter_input_array(INPUT_POST);
1490 $errorCounter = 0;
1491 if (!isset($postData['width']) || empty($postData['width'])) {
1492 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1493 $errorCounter++;
1494 } else if (!isset($postData['type']) || empty($postData['type'])) {
1495 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1496 $errorCounter++;
1497 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1498 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1499 $errorCounter++;
1500 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
1501 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
1502 $errorCounter++;
1503 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
1504 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
1505 $errorCounter++;
1506 } else {
1507 $type = self::sanitize_options($postData['type']);
1508 $nonce = self::sanitize_options($postData['nonce']);
1509 if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
1510 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1511 $errorCounter++;
1512 }
1513 }
1514 if ($errorCounter == 0) {
1515 $type = self::sanitize_options($postData['type']);
1516 $width = self::sanitize_options($postData['width'], "int");
1517 $optionName = "wcp_dynamic_width_for_" . $type;
1518 update_option($optionName, $width);
1519 $response['status'] = 1;
1520 }
1521 echo json_encode($response);
1522 wp_die();
1523 }
1524
1525 public function wcp_change_multiple_post_folder()
1526 {
1527 $response = array();
1528 $response['status'] = 0;
1529 $response['error'] = 0;
1530 $response['data'] = array();
1531 $response['message'] = "";
1532 $postData = filter_input_array(INPUT_POST);
1533 $errorCounter = 0;
1534 if (!isset($postData['post_ids']) || empty($postData['post_ids'])) {
1535 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1536 $errorCounter++;
1537 } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
1538 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1539 $errorCounter++;
1540 } else if (!isset($postData['type']) || empty($postData['type'])) {
1541 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1542 $errorCounter++;
1543 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1544 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1545 $errorCounter++;
1546 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
1547 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1548 $errorCounter++;
1549 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
1550 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1551 $errorCounter++;
1552 } else {
1553 $folder_id = self::sanitize_options($postData['folder_id']);
1554 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$folder_id)) {
1555 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1556 $errorCounter++;
1557 }
1558 }
1559 if ($errorCounter == 0) {
1560 $postID = self::sanitize_options($postData['post_ids']);
1561 $postID = trim($postID, ",");
1562 $folderID = self::sanitize_options($postData['folder_id']);
1563 $type = self::sanitize_options($postData['type']);
1564 $postArray = explode(",", $postID);
1565 $status = 0;
1566 if(isset($postData['status'])) {
1567 $status = self::sanitize_options($postData['status']);
1568 }
1569 $status = true;
1570
1571 $taxonomy = "";
1572 if(isset($postData['taxonomy'])) {
1573 $taxonomy = self::sanitize_options($postData['taxonomy']);
1574 }
1575 if (is_array($postArray)) {
1576 $post_type = self::get_custom_post_type($type);
1577 foreach ($postArray as $post) {
1578 $terms = get_the_terms($post, $post_type);
1579 if (!empty($terms)) {
1580 foreach ($terms as $term) {
1581 if(!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
1582 wp_remove_object_terms($post, $term->term_id, $post_type);
1583 }
1584 }
1585 }
1586 wp_set_post_terms($post, $folderID, $post_type, $status);
1587 }
1588 }
1589 $response['status'] = 1;
1590 }
1591 echo json_encode($response);
1592 wp_die();
1593 }
1594
1595 public function wcp_change_post_folder()
1596 {
1597 $response = array();
1598 $response['status'] = 0;
1599 $response['error'] = 0;
1600 $response['data'] = array();
1601 $response['message'] = "";
1602 $postData = filter_input_array(INPUT_POST);
1603 $errorCounter = 0;
1604 if (!isset($postData['post_id']) || empty($postData['post_id'])) {
1605 $errorCounter++;
1606 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1607 } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
1608 $errorCounter++;
1609 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1610 } else if (!isset($postData['type']) || empty($postData['type'])) {
1611 $errorCounter++;
1612 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1613 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1614 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1615 $errorCounter++;
1616 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
1617 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1618 $errorCounter++;
1619 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
1620 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1621 $errorCounter++;
1622 } else {
1623 $term_id = self::sanitize_options($postData['folder_id']);
1624 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
1625 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1626 $errorCounter++;
1627 }
1628 }
1629 if ($errorCounter == 0) {
1630 $postID = self::sanitize_options($postData['post_id']);
1631 $folderID = self::sanitize_options($postData['folder_id']);
1632 $type = self::sanitize_options($postData['type']);
1633 $folder_post_type = self::get_custom_post_type($type);
1634 $status = 0;
1635 if(isset($postData['status'])) {
1636 $status = self::sanitize_options($postData['status']);
1637 }
1638 $status = ($status == 1)?true:false;
1639 $taxonomy = "";
1640 if(isset($postData['taxonomy'])) {
1641 $taxonomy = self::sanitize_options($postData['taxonomy']);
1642 }
1643 $terms = get_the_terms($postID, $folder_post_type);
1644 if (!empty($terms)) {
1645 foreach ($terms as $term) {
1646 if(!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
1647 wp_remove_object_terms($postID, $term->term_id, $folder_post_type);
1648 }
1649 }
1650 }
1651 wp_set_post_terms($postID, $folderID, $folder_post_type, true);
1652 $response['status'] = 1;
1653 }
1654 echo json_encode($response);
1655 wp_die();
1656 }
1657
1658 public function wcp_mark_un_mark_folder()
1659 {
1660 $response = array();
1661 $response['status'] = 0;
1662 $response['error'] = 0;
1663 $response['data'] = array();
1664 $response['message'] = "";
1665 $postData = filter_input_array(INPUT_POST);
1666 $errorCounter = 0;
1667 if (!current_user_can("manage_categories")) {
1668 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1669 $errorCounter++;
1670 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1671 $errorCounter++;
1672 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1673 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1674 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1675 $errorCounter++;
1676 } else {
1677 $term_id = self::sanitize_options($postData['term_id']);
1678 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_highlight_term_'.$term_id)) {
1679 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1680 $errorCounter++;
1681 }
1682 }
1683 if ($errorCounter == 0) {
1684 $term_id = self::sanitize_options($postData['term_id']);
1685 $status = get_term_meta($term_id, "is_highlighted", true);
1686 if ($status == 1) {
1687 update_term_meta($term_id, "is_highlighted", 0);
1688 $status = 0;
1689 } else {
1690 update_term_meta($term_id, "is_highlighted", 1);
1691 $status = 1;
1692 }
1693 $response['marked'] = $status;
1694 $response['id'] = $postData['term_id'];
1695 $response['status'] = 1;
1696 }
1697 echo json_encode($response);
1698 wp_die();
1699 }
1700
1701 public function wcp_make_sticky_folder()
1702 {
1703 $response = array();
1704 $response['status'] = 0;
1705 $response['error'] = 0;
1706 $response['data'] = array();
1707 $response['message'] = "";
1708 $postData = filter_input_array(INPUT_POST);
1709 $errorCounter = 0;
1710 if (!current_user_can("manage_categories")) {
1711 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1712 $errorCounter++;
1713 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1714 $errorCounter++;
1715 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1716 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1717 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1718 $errorCounter++;
1719 } else {
1720 $term_id = self::sanitize_options($postData['term_id']);
1721 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_highlight_term_'.$term_id)) {
1722 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1723 $errorCounter++;
1724 }
1725 }
1726 if ($errorCounter == 0) {
1727 $term_id = self::sanitize_options($postData['term_id']);
1728 $status = get_term_meta($term_id, "is_folder_sticky", true);
1729 if ($status == 1) {
1730 update_term_meta($term_id, "is_folder_sticky", 0);
1731 $status = 0;
1732 } else {
1733 update_term_meta($term_id, "is_folder_sticky", 1);
1734 $status = 1;
1735 }
1736 $response['is_folder_sticky'] = $status;
1737 $response['id'] = $postData['term_id'];
1738 $response['status'] = 1;
1739 }
1740 echo json_encode($response);
1741 wp_die();
1742 }
1743
1744 public function wcp_save_folder_order()
1745 {
1746 $response = array();
1747 $response['status'] = 0;
1748 $response['error'] = 0;
1749 $response['data'] = array();
1750 $response['message'] = "";
1751 $postData = filter_input_array(INPUT_POST);
1752 $errorCounter = 0;
1753 if (!current_user_can("manage_categories")) {
1754 $response['message'] = esc_attr__("You have not permission to update folder order", WCP_FOLDER);
1755 $errorCounter++;
1756 } else if (!isset($postData['term_ids']) || empty($postData['term_ids'])) {
1757 $errorCounter++;
1758 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1759 } else if (!isset($postData['type']) || empty($postData['type'])) {
1760 $errorCounter++;
1761 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1762 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1763 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1764 $errorCounter++;
1765 } else {
1766 $type = self::sanitize_options($postData['type']);
1767 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
1768 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1769 $errorCounter++;
1770 }
1771 }
1772 if ($errorCounter == 0) {
1773 $termIds = self::sanitize_options(($postData['term_ids']));
1774 $type = self::sanitize_options($postData['type']);
1775 $termIds = trim($termIds, ",");
1776 $termArray = explode(",", $termIds);
1777 $order = 1;
1778 foreach ($termArray as $term) {
1779 if (!empty($term)) {
1780 update_term_meta($term, "wcp_custom_order", $order);
1781 $order++;
1782 }
1783 }
1784 $response['status'] = 1;
1785 $folder_type = self::get_custom_post_type($type);
1786 /* Free/Pro Class name change */
1787 $response['options'] = WCP_Tree::get_option_data_for_select($folder_type);
1788 }
1789 echo json_encode($response);
1790 wp_die();
1791 }
1792
1793 public function save_wcp_folder_state()
1794 {
1795 $response = array();
1796 $response['status'] = 0;
1797 $response['error'] = 0;
1798 $response['data'] = array();
1799 $response['message'] = "";
1800 $postData = filter_input_array(INPUT_POST);
1801 $errorCounter = 0;
1802 if (!current_user_can("manage_categories")) {
1803 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1804 $errorCounter++;
1805 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1806 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1807 $errorCounter++;
1808 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1809 $response['message'] = esc_attr__("Unable to create folder, Your request is not valid", WCP_FOLDER);
1810 $errorCounter++;
1811 } else {
1812 $term_id = self::sanitize_options($postData['term_id']);
1813 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
1814 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1815 $errorCounter++;
1816 }
1817 }
1818 if ($errorCounter == 0) {
1819 $response['status'] = 1;
1820 $term_id = self::sanitize_options($postData['term_id']);
1821 $is_active = isset($postData['is_active'])?$postData['is_active']:0;
1822 $is_active = self::sanitize_options($is_active);
1823 if ($is_active == 1) {
1824 update_term_meta($term_id, "is_active", 1);
1825 } else {
1826 update_term_meta($term_id, "is_active", 0);
1827 }
1828 }
1829 echo json_encode($response);
1830 wp_die();
1831 }
1832
1833 public function wcp_update_parent_information()
1834 {
1835 $response = array();
1836 $response['status'] = 0;
1837 $response['error'] = 0;
1838 $response['data'] = array();
1839 $response['message'] = "";
1840 $postData = filter_input_array(INPUT_POST);
1841 $errorCounter = 0;
1842 if (!current_user_can("manage_categories")) {
1843 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1844 $errorCounter++;
1845 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1846 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1847 $errorCounter++;
1848 } else if (!isset($postData['type']) || empty($postData['type'])) {
1849 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1850 $errorCounter++;
1851 } else if (!isset($postData['parent_id'])) {
1852 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1853 $errorCounter++;
1854 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1855 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1856 $errorCounter++;
1857 } else {
1858 $term_id = self::sanitize_options($postData['term_id']);
1859 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
1860 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1861 $errorCounter++;
1862 }
1863 }
1864 if($errorCounter == 0) {
1865 $term_id = self::sanitize_options($postData['term_id']);
1866 $parent_id = self::sanitize_options($postData['parent_id']);
1867 $type = self::sanitize_options($postData['type']);
1868 $folder_type = self::get_custom_post_type($type);
1869 wp_update_term($term_id, $folder_type, array(
1870 'parent' => $parent_id
1871 ));
1872 update_term_meta($parent_id, "is_active", 1);
1873 $response['status'] = 1;
1874 }
1875 echo json_encode($response);
1876 wp_die();
1877 }
1878
1879 public function wcp_save_parent_data()
1880 {
1881 $response = array();
1882 $response['status'] = 0;
1883 $response['error'] = 0;
1884 $response['data'] = array();
1885 $response['message'] = "";
1886 $postData = filter_input_array(INPUT_POST);
1887 $errorCounter = 0;
1888 if (!isset($postData['type']) || empty($postData['type'])) {
1889 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1890 $errorCounter++;
1891 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1892 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1893 $errorCounter++;
1894 } else if (!current_user_can("manage_categories")) {
1895 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1896 $errorCounter++;
1897 } else {
1898 $type = self::sanitize_options($postData['type']);
1899 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
1900 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1901 $errorCounter++;
1902 }
1903 }
1904 if ($errorCounter == 0) {
1905 $type = self::sanitize_options($postData['type']);
1906 $optionName = $type . "_parent_status";
1907 $response['status'] = 1;
1908 $is_active = isset($postData['is_active'])?$postData['is_active']:0;
1909 $is_active = self::sanitize_options($is_active);
1910 if ($is_active == 1) {
1911 update_option($optionName, 1);
1912 } else {
1913 update_option($optionName, 0);
1914 }
1915 }
1916 echo json_encode($response);
1917 wp_die();
1918 }
1919
1920 public function remove_muliple_folder(){
1921 $response = array();
1922 $response['status'] = 0;
1923 $response['error'] = 0;
1924 $response['data'] = array();
1925 $response['message'] = "";
1926 $postData = filter_input_array(INPUT_POST);
1927 $errorCounter = 0;
1928 $error = "";
1929 if (!current_user_can("manage_categories")) {
1930 $error = esc_attr__("You have not permission to remove folder", WCP_FOLDER);
1931 $errorCounter++;
1932 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1933 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
1934 $errorCounter++;
1935 } else if (!isset($postData['type']) || empty($postData['type'])) {
1936 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
1937 $errorCounter++;
1938 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1939 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1940 $errorCounter++;
1941 } else {
1942 $type = self::sanitize_options($postData['type']);
1943 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
1944 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
1945 $errorCounter++;
1946 }
1947 }
1948 if ($errorCounter == 0) {
1949 $term_id = self::sanitize_options($postData['term_id']);
1950 $type = self::sanitize_options($postData['type']);
1951 if(!empty($term_id)) {
1952 $term_id = trim($term_id,",");
1953 $term_ids = explode(",", $term_id);
1954 if(is_array($term_ids) && count($term_ids) > 0) {
1955 foreach ($term_ids as $term) {
1956 self::remove_folder_child_items($term, $type);
1957 }
1958 }
1959 }
1960 $is_active = 1;
1961 $folders = -1;
1962 $response['status'] = 1;
1963 if (!self::check_has_valid_key()) {
1964 $is_active = 0;
1965 $folders = self::ttl_fldrs();
1966 }
1967 $response['folders'] = $folders;
1968 $response['is_key_active'] = $is_active;
1969 } else {
1970 $response['error'] = 1;
1971 $response['message'] = $error;
1972 }
1973 echo json_encode($response);
1974 wp_die();
1975 }
1976
1977 public function wcp_remove_folder()
1978 {
1979 $response = array();
1980 $response['status'] = 0;
1981 $response['error'] = 0;
1982 $response['data'] = array();
1983 $response['message'] = "";
1984 $postData = filter_input_array(INPUT_POST);
1985 $errorCounter = 0;
1986 if (!current_user_can("manage_categories")) {
1987 $error = esc_attr__("You have not permission to remove folder", WCP_FOLDER);
1988 $errorCounter++;
1989 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1990 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
1991 $errorCounter++;
1992 } else if (!isset($postData['type']) || empty($postData['type'])) {
1993 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
1994 $errorCounter++;
1995 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1996 $error = esc_attr__("Unable to delete folder, Your request is not valid", WCP_FOLDER);
1997 $errorCounter++;
1998 } else {
1999 $term_id = self::sanitize_options($postData['term_id']);
2000 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_delete_term_'.$term_id)) {
2001 $error = esc_attr__("Unable to delete folder, Your request is not valid", WCP_FOLDER);
2002 $errorCounter++;
2003 }
2004 }
2005 if ($errorCounter == 0) {
2006 $term_id = self::sanitize_options($postData['term_id']);
2007 $type = self::sanitize_options($postData['type']);
2008 self::remove_folder_child_items($term_id, $type);
2009 $response['status'] = 1;
2010 $is_active = 1;
2011 $folders = -1;
2012 if (!self::check_has_valid_key()) {
2013 $is_active = 0;
2014 $folders = self::ttl_fldrs();
2015 }
2016 $response['folders'] = $folders;
2017 $response['is_key_active'] = $is_active;
2018 } else {
2019 $response['error'] = 1;
2020 $response['message'] = $error;
2021 }
2022 echo json_encode($response);
2023 wp_die();
2024 }
2025
2026 public function remove_folder_child_items($term_id, $post_type)
2027 {
2028 $folder_type = self::get_custom_post_type($post_type);
2029 $terms = get_terms($folder_type, array(
2030 'hide_empty' => false,
2031 'parent' => $term_id
2032 ));
2033
2034 if (!empty($terms)) {
2035 foreach ($terms as $term) {
2036 self::remove_folder_child_items($term->term_id, $post_type);
2037 }
2038 wp_delete_term($term_id, $folder_type);
2039 } else {
2040 wp_delete_term($term_id, $folder_type);
2041 }
2042 }
2043
2044 public function wcp_update_folder()
2045 {
2046 $response = array();
2047 $response['status'] = 0;
2048 $response['error'] = 0;
2049 $response['data'] = array();
2050 $response['message'] = "";
2051 $postData = $_REQUEST;
2052 $errorCounter = 0;
2053 if (!current_user_can("manage_categories")) {
2054 $error = esc_attr__("You have not permission to update folder", WCP_FOLDER);
2055 $errorCounter++;
2056 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
2057 $error = esc_attr__("Unable to rename folder, Your request is not valid", WCP_FOLDER);
2058 $errorCounter++;
2059 } else if (!isset($postData['name']) || empty($postData['name'])) {
2060 $error = esc_attr__("Folder name can no be empty", WCP_FOLDER);
2061 $errorCounter++;
2062 } else if (!isset($postData['type']) || empty($postData['type'])) {
2063 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
2064 $errorCounter++;
2065 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2066 $error = esc_attr__("Unable to rename folder, Your request is not valid", WCP_FOLDER);
2067 $errorCounter++;
2068 } else {
2069 $term_id = self::sanitize_options($postData['term_id']);
2070 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_rename_term_'.$term_id)) {
2071 $error = esc_attr__("Unable to rename folder, Your request is not valid", WCP_FOLDER);
2072 $errorCounter++;
2073 }
2074 }
2075 if ($errorCounter == 0) {
2076 $type = self::sanitize_options($postData['type']);
2077 $folder_type = self::get_custom_post_type($type);
2078 $name = self::sanitize_options($postData['name']);
2079 $term_id = self::sanitize_options($postData['term_id']);
2080 $result = wp_update_term(
2081 $term_id,
2082 $folder_type,
2083 array(
2084 'name' => $name,
2085 )
2086 );
2087 if (!empty($result)) {
2088 $response['id'] = $result['term_id'];
2089 $response['status'] = 1;
2090 $response['term_title'] = $postData['name'];
2091 } else {
2092 $response['message'] = esc_attr__("Unable to rename folder", WCP_FOLDER);
2093 }
2094 } else {
2095 $response['error'] = 1;
2096 $response['message'] = $error;
2097 }
2098 echo json_encode($response);
2099 wp_die();
2100 }
2101
2102 public function create_slug_from_string($str)
2103 {
2104 $a = array('À', 'Á', 'Â', 'Ã', 'Ä', '�
2105 ', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'Ð', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', '?', '?', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', '?', '?', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', '?', 'O', 'o', 'O', 'o', 'O', 'o', 'Œ', 'œ', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'Š', 'š', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Ÿ', 'Z', 'z', 'Z', 'z', 'Ž', 'ž', '?', 'ƒ', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', '?', '?', '?', '?', '?', '?');
2106 $b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
2107 return strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), str_replace($a, $b, $str)));
2108 }
2109
2110 public static function sanitize_options($value, $type = "") {
2111 $value = stripslashes($value);
2112 if($type == "int") {
2113 $value = filter_var($value, FILTER_SANITIZE_NUMBER_INT);
2114 } else if($type == "email") {
2115 $value = filter_var($value, FILTER_SANITIZE_EMAIL);
2116 } else {
2117 $value = filter_var($value, FILTER_SANITIZE_STRING);
2118 }
2119 return $value;
2120 }
2121
2122 public function wcp_add_new_folder()
2123 {
2124 $response = array();
2125 $response['status'] = 0;
2126 $response['error'] = 0;
2127 $response['login'] = 1;
2128 $response['data'] = array();
2129 $response['message'] = "";
2130 $postData = $_REQUEST;
2131 $errorCounter = 0;
2132 if (!current_user_can("manage_categories")) {
2133 $error = esc_attr__("You have not permission to add folder", WCP_FOLDER);
2134 $errorCounter++;
2135 } else if (!isset($postData['name']) || empty($postData['name'])) {
2136 $error = esc_attr__("Folder name can no be empty", WCP_FOLDER);
2137 $errorCounter++;
2138 } else if (!isset($postData['type']) || empty($postData['type'])) {
2139 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
2140 $errorCounter++;
2141 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2142 $response['login'] = 0;
2143 $error = esc_attr__("Unable to create folder, Your request is not valid", WCP_FOLDER);
2144 $errorCounter++;
2145 } else {
2146 $type = self::sanitize_options($postData['type']);
2147 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
2148 $response['login'] = 0;
2149 $error = esc_attr__("Unable to create folder, Your request is not valid", WCP_FOLDER);
2150 $errorCounter++;
2151 }
2152 }
2153 if ($errorCounter == 0) {
2154 $parent = isset($postData['parent_id']) && !empty($postData['parent_id']) ? $postData['parent_id'] : 0;
2155 $parent = self::sanitize_options($parent);
2156 $type = self::sanitize_options($postData['type']);
2157 $folder_type = self::get_custom_post_type($type);
2158 $term_name = self::sanitize_options($postData['name']);
2159 $term = term_exists($term_name, $folder_type, $parent);
2160 if (!(0 !== $term && null !== $term)) {
2161 $slug = self::create_slug_from_string($postData['name']) . "-" . time();
2162 $result = wp_insert_term(
2163 $postData['name'], // the term
2164 $folder_type, // the taxonomy
2165 array(
2166 'parent' => $parent,
2167 'slug' => $slug
2168 )
2169 );
2170 if (!empty($result)) {
2171 $response['id'] = $result['term_id'];
2172 $response['status'] = 1;
2173 $term = get_term($result['term_id'], $folder_type);
2174 $order = isset($postData['order']) ? $postData['order'] : 0;
2175 $order = self::sanitize_options($order);
2176 update_term_meta($result['term_id'], "wcp_custom_order", $order);
2177 if ($parent != 0) {
2178 update_term_meta($parent, "is_active", 1);
2179 }
2180
2181 $count = "";
2182 $class = "";
2183
2184 if(isset($postData['is_duplicate']) && $postData['is_duplicate'] == true) {
2185 if(isset($postData['duplicate_from']) && !empty($postData['duplicate_from'])) {
2186 $term_id = $postData['duplicate_from'];
2187
2188 $term_data = get_term($term_id, $folder_type);
2189 if(!empty($term_data)) {
2190 $is_sticky = get_term_meta($term_id, "is_folder_sticky", true);
2191
2192 if($is_sticky == 1) {
2193 $class .= " is-sticky";
2194 add_term_meta($term->term_id, "is_folder_sticky", 1);
2195 }
2196
2197 $status = get_term_meta($term_id, "is_highlighted", true);
2198 if($status == 1) {
2199 add_term_meta($term->term_id, "is_highlighted", 1);
2200 $class .= " is-high";
2201 }
2202
2203 $count = ($term_data->count != 0)?"<span class='total-count'>{$term_data->count}</span>":"";
2204
2205 // if(!empty($term_data->count)) {
2206 $postArray = get_posts(
2207 array(
2208 'posts_per_page' => -1,
2209 'post_type' => $type,
2210 'tax_query' => array(
2211 array(
2212 'taxonomy' => $folder_type,
2213 'field' => 'term_id',
2214 'terms' => $term_id,
2215 )
2216 )
2217 )
2218 );
2219 if(!empty($postArray)) {
2220 foreach($postArray as $p) {
2221 wp_set_post_terms($p->ID, $term->term_id, $folder_type, true);
2222 }
2223 }
2224 // }
2225 }
2226 }
2227 }
2228 $delete_nonce = wp_create_nonce('wcp_folder_delete_term_'.$term->term_id);
2229 $rename_nonce = wp_create_nonce('wcp_folder_rename_term_'.$term->term_id);
2230 $highlight_nonce = wp_create_nonce('wcp_folder_highlight_term_'.$term->term_id);
2231 $term_nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
2232 /* Free/Pro URL Change */
2233 /* Free/Pro URL Change*/
2234 $string = "<li data-nonce='{$term_nonce}' data-star='{$highlight_nonce}' data-rename='{$rename_nonce}' data-delete='{$delete_nonce}' data-slug='{$term->slug}' class='ui-state-default route wcp_folder_{$term->term_id} {$class}' id='wcp_folder_{$term->term_id}' data-folder-id='{$term->term_id}'>";
2235 $string .= "<h3 class='title' title='{$term->name}' id='title_{$term->term_id}'>";
2236 $string .= "<span class='ui-icon'>";
2237 $string .= "<i class='wcp-icon pfolder-folder-close'></i>";
2238 $string .= "<input type='checkbox' class='checkbox' value='{$term->term_id}' />";
2239 $string .= "</span>";
2240 $string .= "<span class='title-text'>{$term->name}</span>";
2241 $string .= "{$count} <span class='update-inline-record'><i class='pfolder-edit-folder'></i></span> <span class='star-icon'><i class='pfolder-star'></i></span>";
2242 $string .= "<span class='folder-sticky-icon'><i class='pfolder-pin'></i></span>";
2243 // $string .= "<span class='move-folder-icon' ><i class='pfolder-move'></i></span>";
2244 $string .= "</h3>";
2245 $string .= "<span class='nav-icon'><i class='wcp-icon pfolder-arrow-down'></i></span>";
2246 $string .= "<ul class='space' id='space_{$term->term_id}'>";
2247 $string .= "</ul></li>";
2248 $response['term_data'] = $string;
2249 $response['parent_id'] = $parent;
2250 $response['term_id'] = $result['term_id'];
2251
2252 $is_active = 1;
2253 $folders = -1;
2254 if (!self::check_has_valid_key()) {
2255 $is_active = 0;
2256 $folders = self::ttl_fldrs();
2257 }
2258 $response['is_key_active'] = $is_active;
2259 $response['folders'] = $folders;
2260 } else {
2261 $response['message'] = esc_attr__("Error during server request", WCP_FOLDER);
2262 }
2263 } else {
2264 $response['error'] = 1;
2265 $response['message'] = esc_attr__("Folder name already exists", WCP_FOLDER);
2266 }
2267 } else {
2268 $response['error'] = 1;
2269 $response['message'] = $error;
2270 }
2271 echo json_encode($response);
2272 wp_die();
2273 }
2274
2275 public function is_for_this_post_type($post_type)
2276 {
2277 $post_types = get_option(WCP_FOLDER_VAR);
2278 $post_types = is_array($post_types)?$post_types:array();
2279 return in_array($post_type, $post_types);
2280 }
2281
2282 public function is_active_for_screen()
2283 {
2284 global $typenow, $current_screen;
2285
2286 $postData = filter_input_array(INPUT_POST);
2287
2288
2289 // if ((isset($postData['action']) && $postData['action'] == 'inline-save') && (isset($postData['post_type']) && self::is_for_this_post_type($postData['post_type']))) {
2290 // return true;
2291 // }
2292 global $current_screen;
2293
2294 if (self::is_for_this_post_type($typenow) && ('edit' == $current_screen->base || 'upload' == $current_screen->base)) {
2295 return true;
2296 }
2297
2298 $post_types = get_option(WCP_FOLDER_VAR);
2299 $post_types = is_array($post_types)?$post_types:array();
2300
2301 if(empty($typenow) && 'upload' == $current_screen->base ) {
2302 $typenow = "attachment";
2303 if (self::is_for_this_post_type($typenow)) {
2304 return true;
2305 }
2306 }
2307 return false;
2308 }
2309
2310 public function is_add_update_screen()
2311 {
2312 global $current_screen;
2313 $current_type = $current_screen->base;
2314 $action = $current_screen->action;
2315 $post_types = get_option(WCP_FOLDER_VAR);
2316 $post_types = is_array($post_types)?$post_types:array();
2317 global $typenow;
2318 if (in_array($current_type, $post_types) && in_array($action, array("add", ""))) {
2319 $license_data = self::get_license_key_data();
2320
2321 $is_active = 1;
2322 $folders = -1;
2323 if (!self::check_has_valid_key()) {
2324 $is_active = 0;
2325 $folders = self::ttl_fldrs();
2326 }
2327 $response['folders'] = $folders;
2328 $response['is_key_active'] = $is_active;
2329 }
2330 }
2331
2332 public static function get_custom_post_type($post_type)
2333 {
2334 if ($post_type == "post") {
2335 return "post_folder";
2336 } else if ($post_type == "page") {
2337 return "folder";
2338 } else if ($post_type == "attachment") {
2339 return "media_folder";
2340 }
2341 return $post_type . '_folder';
2342 }
2343
2344 public function admin_footer()
2345 {
2346 if (self::is_active_for_screen()) {
2347 global $typenow;
2348
2349 self::set_default_values_if_not_exists();
2350
2351 $ttpsts = self::get_ttlpst($typenow);
2352
2353 $ttemp = self::get_tempt_posts($typenow);
2354
2355 $folder_type = self::get_custom_post_type($typenow);
2356 /* Do not change: Free/Pro Class name change */
2357 $tree_data = WCP_Tree::get_full_tree_data($folder_type);
2358 $terms_data = $tree_data['string'];
2359 $sticky_string = $tree_data['sticky_string'];
2360 $terms_html = WCP_Tree::get_option_data_for_select($folder_type);
2361 $form_html = WCP_Forms::get_form_html($terms_html);
2362 include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "admin-content.php";
2363 }
2364
2365 global $pagenow;
2366 if ( 'plugins.php' !== $pagenow ) {
2367
2368 } else {
2369 if (current_user_can('manage_options')) {
2370 include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "folder-deactivate-form.php";
2371 }
2372 }
2373 }
2374
2375 public function get_ttlpst($post_type = "")
2376 {
2377 global $typenow;
2378 if (empty($post_type)) {
2379 $post_type = $typenow;
2380 }
2381 $item_count = null;
2382 if(has_filter("premio_folder_all_categorized_items")) {
2383 $item_count = apply_filters("premio_folder_all_categorized_items", $post_type);
2384 }
2385 if($item_count === null) {
2386 if ($post_type == "attachment") {
2387 $item_count = wp_count_posts($post_type)->inherit;
2388 } else {
2389 $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;
2390 }
2391 }
2392 return $item_count;
2393 }
2394
2395 public function autoload()
2396 {
2397 $files = array(
2398 'WCP_Tree_View' => WCP_DS . "includes" . WCP_DS . "tree.class.php",
2399 'WCP_Form_View' => WCP_DS . "includes" . WCP_DS . "form.class.php",
2400 'WCP_Folder_WPML' => WCP_DS . "includes" . WCP_DS . "class-wpml.php",
2401 'WCP_Folder_PolyLang' => WCP_DS . "includes" . WCP_DS . "class-polylang.php",
2402 );
2403
2404 foreach ($files as $file) {
2405 if (file_exists(dirname(dirname(__FILE__)) . $file)) {
2406 include_once dirname(dirname(__FILE__)) . $file;
2407 }
2408 }
2409 }
2410
2411 public function create_folder_terms()
2412 {
2413 $options = get_option(WCP_FOLDER_VAR);
2414 $options = is_array($options)?$options:array();
2415 $old_plugin_status = 0;
2416 $posts = array();
2417 if (!empty($options)) {
2418 foreach ($options as $option) {
2419 if (!(strpos($option, 'folder4') === false) && $old_plugin_status == 0) {
2420 $old_plugin_status = 1;
2421 }
2422 if (in_array($option, array("page", "post", "attachment"))) {
2423 $posts[] = str_replace("folder4", "", $option);
2424 } else {
2425 $posts[] = $option;
2426 }
2427 }
2428 if(!empty($posts)) {
2429 update_option(WCP_FOLDER_VAR, $posts);
2430 }
2431 }
2432 if ($old_plugin_status == 1) {
2433 update_option("folders_show_in_menu", "on");
2434 $old_plugin_var = get_option("folder_old_plugin_status");
2435 if (empty($old_plugin_var) || $old_plugin_var == null) {
2436 update_option("folder_old_plugin_status", "1");
2437 }
2438 }
2439 $posts = get_option(WCP_FOLDER_VAR);
2440 if (!empty($posts)) {
2441 foreach ($posts as $post_type) {
2442 $labels = array(
2443 'name' => esc_html__('Folders', WCP_FOLDER),
2444 'singular_name' => esc_html__('Folder', WCP_FOLDER),
2445 'all_items' => esc_html__('All Folders', WCP_FOLDER),
2446 'edit_item' => esc_html__('Edit Folder', WCP_FOLDER),
2447 'update_item' => esc_html__('Update Folder', WCP_FOLDER),
2448 'add_new_item' => esc_html__('Add New Folder', WCP_FOLDER),
2449 'new_item_name' => esc_html__('Add folder name', WCP_FOLDER),
2450 'menu_name' => esc_html__('Folders', WCP_FOLDER),
2451 'search_items' => esc_html__('Search Folders', WCP_FOLDER),
2452 'parent_item' => esc_html__('Parent Folder', WCP_FOLDER),
2453 );
2454
2455 $args = array(
2456 'label' => esc_html__('Folder', WCP_FOLDER),
2457 'labels' => $labels,
2458 'show_tagcloud' => false,
2459 'hierarchical' => true,
2460 'public' => false,
2461 'show_ui' => true,
2462 'show_in_menu' => false,
2463 'show_in_rest' => true,
2464 'show_admin_column' => true,
2465 'update_count_callback' => '_update_generic_term_count',
2466 'query_var' => true,
2467 'rewrite' => false,
2468 'capabilities' => array(
2469 'manage_terms' => 'manage_categories',
2470 'edit_terms' => 'manage_categories',
2471 'delete_terms' => 'manage_categories',
2472 'assign_terms' => 'manage_categories'
2473 )
2474 );
2475
2476 $folder_post_type = self::get_custom_post_type($post_type);
2477
2478 register_taxonomy(
2479 $folder_post_type,
2480 $post_type,
2481 $args
2482 );
2483 }
2484 }
2485
2486 $postData = filter_input_array(INPUT_POST);
2487
2488 if(current_user_can("manage_categories") && isset($postData['folder_nonce'])) {
2489 if(wp_verify_nonce($postData['folder_nonce'], "folder_settings")) {
2490 if (isset($postData['folders_show_in_menu']) && !empty($postData['folders_show_in_menu'])) {
2491 $show_menu = "off";
2492 if ($postData['folders_show_in_menu'] == "on") {
2493 $show_menu = "on";
2494 }
2495 update_option("folders_show_in_menu", $show_menu);
2496 }
2497
2498 if (isset($postData['folders_settings1'])) {
2499 $posts = array();
2500 if (isset($postData['folders_settings']) && is_array($postData['folders_settings'])) {
2501 foreach ($postData['folders_settings'] as $key => $val) {
2502 $posts[] = $val;
2503 }
2504 }
2505 update_option("folders_settings", $posts);
2506 }
2507
2508 if (isset($_POST['folders_settings1'])) {
2509 $posts = array();
2510 if (isset($_POST['default_folders']) && is_array($_POST['default_folders'])) {
2511 foreach ($_POST['default_folders'] as $key => $val) {
2512 $posts[$key] = $val;
2513 }
2514 }
2515 update_option("default_folders", $posts);
2516 }
2517
2518 if (isset($_POST['folders_settings1'])) {
2519 $posts = array();
2520 if (isset($_POST['customize_folders']) && is_array($_POST['customize_folders'])) {
2521 foreach ($_POST['customize_folders'] as $key => $val) {
2522 $posts[$key] = $val;
2523 }
2524 }
2525 update_option("customize_folders", $posts);
2526 }
2527 }
2528 }
2529
2530 $old_version = get_option("folder_old_plugin_status");
2531 if($old_version !== false && $old_version == 1) {
2532 $tlfs = get_option("folder_old_plugin_folder_status");
2533 if($tlfs === false) {
2534 $total = self::ttl_fldrs();
2535 if($total <= 10) {
2536 $total = 10;
2537 };
2538 update_option("folder_old_plugin_folder_status", $total);
2539 self::$folders = $total;
2540 } else {
2541 self::$folders = $tlfs;
2542 }
2543 }
2544
2545 $tlfs = get_option("folder_old_plugin_folder_status");
2546 if($tlfs === false) {
2547 self::$folders = 10;
2548 } else {
2549 self::$folders = $tlfs;
2550 }
2551 }
2552
2553 function searchForId($id, $menu)
2554 {
2555 if ($menu) {
2556 foreach ($menu as $key => $val) {
2557 if (array_key_exists(2, $val)) {
2558 $stripVal = explode('=', $val[2]);
2559 }
2560 if (array_key_exists(1, $stripVal)) {
2561 $stripVal = $stripVal[1];
2562 }
2563 if ($stripVal === $id) {
2564 return $key;
2565 }
2566 }
2567 }
2568 }
2569
2570 function create_menu_for_folders()
2571 {
2572 global $menu;
2573 self::check_and_set_post_type();
2574
2575 $folder_types = get_option("folders_settings");
2576 if (empty($folder_types)) {
2577 return;
2578 }
2579
2580 foreach ($folder_types as $type) {
2581 $itemKey = self::searchForId($type, $menu);
2582 switch (true) {
2583 case ($type == 'attachment'):
2584 $itemKey = 10;
2585 $edit = 'upload.php';
2586 break;
2587 case ($type === 'post'):
2588 $edit = 'edit.php';
2589 $itemKey = 5;
2590 break;
2591 default:
2592 $edit = 'edit.php';
2593 break;
2594 }
2595
2596 $folder = $type == 'attachment' ? 'media' : $type;
2597 $upper = $type == 'attachment' ? 'Media' : ucwords(str_replace(array('-', '_'), ' ', $type));
2598 if ($type == 'page') {
2599 $tax_slug = 'folder';
2600 } else {
2601 $tax_slug = $folder . '_folder';
2602 }
2603
2604
2605 if ($type == 'attachment') {
2606 add_menu_page('Media Folders', 'Media Folders', 'publish_pages', "{$edit}?type=folder", false, 'dashicons-portfolio', "{$itemKey}.5");
2607 } else {
2608 add_menu_page($upper . ' Folders', "{$upper} Folders", 'publish_pages', "{$edit}?post_type={$type}&type=folder", false, 'dashicons-portfolio', "{$itemKey}.5");
2609 }
2610 $terms = get_terms($tax_slug, array(
2611 'hide_empty' => true,
2612 'parent' => 0,
2613 'orderby' => 'meta_value_num',
2614 'order' => 'ASC',
2615 'hierarchical' => false,
2616 'meta_query' => [[
2617 'key' => 'wcp_custom_order',
2618 'type' => 'NUMERIC',
2619 ]]
2620 )
2621 );
2622
2623 if ($terms) {
2624 foreach ($terms as $term) {
2625 if ($type == 'attachment') {
2626 add_submenu_page("{$edit}?type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type=attachment&media_folder={$term->slug}", false);
2627 } else {
2628 add_submenu_page("{$edit}?post_type={$type}&type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type={$type}&{$tax_slug}={$term->slug}", false);
2629 }
2630 }
2631 }
2632 }
2633 }
2634
2635 function folders_admin_styles()
2636 {
2637 if (self::is_active_for_screen()) {
2638 wp_register_style('wcp-folders-fa', plugin_dir_url(dirname(__FILE__)) . 'assets/css/folder-icon.css', array(), WCP_FOLDER_VERSION);
2639 wp_enqueue_style('wcp-folders-fa');
2640 wp_register_style('wcp-folders-admin', plugin_dir_url(dirname(__FILE__)) . 'assets/css/design.min.css', array(), WCP_FOLDER_VERSION);
2641 wp_enqueue_style('wcp-folders-admin');
2642 }
2643 wp_register_style('wcp-css-handle', false);
2644 wp_enqueue_style('wcp-css-handle');
2645 $css = "
2646 .wcp-folder-upgrade-button {color: #FF5983; font-weight: bold;}
2647 ";
2648 if (self::is_active_for_screen()) {
2649 global $typenow;
2650 $width = get_option("wcp_dynamic_width_for_" . $typenow);
2651 $width = esc_attr($width);
2652 $display_status = "wcp_dynamic_display_status_" . $typenow;
2653 $display_status = get_option($display_status);
2654 if($display_status != "hide") {
2655 if (!empty($width) && is_numeric($width)) {
2656 $css .= ".wcp-content{width:{$width}px}";
2657 if (function_exists('is_rtl') && is_rtl()) {
2658 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:" . ($width + 20) . "px}";
2659 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}";
2660 } else {
2661 $css .= "body.wp-admin #wpcontent {padding-left:" . ($width + 20) . "px}";
2662 }
2663 }
2664 } else {
2665 if (function_exists('is_rtl') && is_rtl()) {
2666 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:20px}";
2667 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}";
2668 } else {
2669 $css .= "body.wp-admin #wpcontent {padding-left:20px}";
2670 }
2671 }
2672 if (!empty($width) && is_numeric($width)) {
2673 $css .= ".wcp-content {width: {$width}px}";
2674 }
2675 }
2676 wp_add_inline_style('wcp-css-handle', $css);
2677
2678 if (self::is_active_for_screen()) {
2679 global $typenow;
2680 add_filter('views_edit-' . $typenow, array($this, 'wcp_check_for_child_folders'));
2681 }
2682 }
2683
2684 function wcp_check_for_child_folders($content)
2685 {
2686 $termId = 0;
2687 global $typenow;
2688 $post_type = self::get_custom_post_type($typenow);
2689 if (isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
2690 $term = $_GET[$post_type];
2691 $term = get_term_by("slug", $term, $post_type);
2692 if (!empty($term)) {
2693 $termId = $term->term_id;
2694 }
2695 }
2696 $terms = get_terms($post_type, array(
2697 'hide_empty' => false,
2698 'parent' => $termId,
2699 'orderby' => 'meta_value_num',
2700 'order' => 'ASC',
2701 'hierarchical' => false,
2702 'update_count_callback' => '_update_generic_term_count',
2703 'meta_query' => [[
2704 'key' => 'wcp_custom_order',
2705 'type' => 'NUMERIC',
2706 ]]
2707 ));
2708 $optionName = "wcp_folder_display_status_" . $typenow;
2709 $optionValue = get_option($optionName);
2710 $class = (!empty($optionValue) && $optionValue == "hide")?"":"active";
2711 $customize_folders = get_option('customize_folders');
2712 $show_in_page = !isset($customize_folders['show_in_page'])||empty($customize_folders['show_in_page'])?"show":$customize_folders['show_in_page'];
2713 if(empty($show_in_page)) {
2714 $show_in_page = "show";
2715 }
2716 if($show_in_page == "show") {
2717 echo '<div class="tree-structure-content ' . $class . '"><div class="tree-structure" id="list-folder-' . $termId . '" data-id="' . $termId . '">';
2718 echo '<ul>';
2719 foreach ($terms as $term) {
2720 $status = get_term_meta($term->term_id, "is_highlighted", true);
2721 ?>
2722 <li class="grid-view" data-id="<?php echo $term->term_id ?>" id="folder_<?php echo $term->term_id ?>">
2723 <div class="folder-item is-folder" data-id="<?php echo $term->term_id ?>">
2724 <a title='<?php echo $term->name ?>' id="folder_view_<?php echo $term->term_id ?>"
2725 class="folder-view <?php echo ($status == 1) ? "is-high" : "" ?>"
2726 data-id="<?php echo $term->term_id ?>">
2727 <span class="folder item-name"><span id="wcp_folder_text_<?php echo $term->term_id ?>"
2728 class="folder-title"><?php echo $term->name ?></span></span>
2729 <!--<span class="folder-option"></span>-->
2730 </a>
2731 </div>
2732 </li>
2733 <?php
2734 }
2735 echo '</ul>';
2736 echo '<div class="clear clearfix"></div>';
2737 echo '</div>';
2738 echo '<div class="folders-toggle-button"><span></span></div>';
2739 echo '</div>';
2740 }
2741 if(!empty($content) && is_array($content)) {
2742 echo '<ul class="subsubsub">';
2743 foreach($content as $k=>$v) {
2744 echo "<li class='{$k}'>{$v}</li>";
2745 }
2746 echo '</ul>';
2747 }
2748 }
2749
2750 function folders_admin_scripts($hook)
2751 {
2752 if (self::is_active_for_screen()) {
2753 global $typenow;
2754 /* Free/Pro Version change */
2755 wp_register_script('wcp-folders-alert', plugin_dir_url(dirname(__FILE__)) . 'assets/js/livequery.min.js', array(), WCP_FOLDER_VERSION);
2756 wp_register_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)) . 'assets/js/custom.js', array('jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION);
2757
2758
2759 $post_type = self::get_custom_post_type($typenow);
2760
2761 if ($typenow == "attachment") {
2762 $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
2763 } else {
2764 $admin_url = admin_url("edit.php?post_type=" . $typenow);
2765 if (isset($_GET['s']) && !empty($_GET['s'])) {
2766 $admin_url .= "&s=" . $_GET['s'];
2767 }
2768 $admin_url .= "&{$post_type}=";
2769 }
2770
2771 $current_url = $admin_url;
2772 if(isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
2773 $current_url .= $_GET[$post_type];
2774 }
2775
2776
2777 $is_active = 1;
2778 $folders = -1;
2779 if (!self::check_has_valid_key()) {
2780 $is_active = 0;
2781 $folders = self::ttl_fldrs();
2782 }
2783 /* For free: upgrade URL, for Pro: Register Key URL */
2784 $register_url = admin_url("admin.php?page=wcp_folders_upgrade");
2785
2786 $is_rtl = 0;
2787 if ( function_exists( 'is_rtl' ) && is_rtl() ) {
2788 $is_rtl = 1;
2789 }
2790
2791 $can_manage_folder = current_user_can("manage_categories")?1:0;
2792 $width = get_option("wcp_dynamic_width_for_" . $typenow);
2793 $width = empty($width)||!is_numeric($width)?310:$width;
2794 $post_type = self::get_custom_post_type($typenow);
2795 $taxonomy_status = 0;
2796 $selected_taxonomy = "";
2797 if(!isset($_GET[$post_type]) || empty($_GET[$post_type])) {
2798 $taxonomy_status = 1;
2799 } else if(isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
2800 $selected_taxonomy = $_GET[$post_type];
2801
2802 $term = get_term_by('slug', $selected_taxonomy, $post_type);
2803 if (!empty($term) && is_object($term)) {
2804 $selected_taxonomy = $term->term_id;
2805 } else {
2806 $selected_taxonomy = "";
2807 }
2808 }
2809 $customize_folders = get_option('customize_folders');
2810 $show_in_page = !isset($customize_folders['show_in_page'])||empty($customize_folders['show_in_page'])?"show":$customize_folders['show_in_page'];
2811 if(empty($show_in_page)) {
2812 $show_in_page = "show";
2813 }
2814 wp_localize_script('wcp-folders-custom', 'wcp_settings', array(
2815 'ajax_url' => admin_url('admin-ajax.php'),
2816 'upgrade_url' => admin_url('admin.php?page=wcp_folders_upgrade'),
2817 'post_type' => $typenow,
2818 'page_url' => $admin_url,
2819 'current_url' => $current_url,
2820 'ajax_image' => plugin_dir_url(dirname(__FILE__)) . "assets/images/ajax-loader.gif",
2821 'is_key_active' => $is_active,
2822 'folders' => $folders,
2823 'register_url' => $register_url,
2824 'isRTL' => $is_rtl,
2825 'nonce' => wp_create_nonce('wcp_folder_nonce_'.$typenow),
2826 'can_manage_folder' => $can_manage_folder,
2827 'folder_width' => $width,
2828 'taxonomy_status' => $taxonomy_status,
2829 'selected_taxonomy' => $selected_taxonomy,
2830 'show_in_page' => $show_in_page,
2831 'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png',
2832 ));
2833 wp_enqueue_script('wcp-folders-alert');
2834 wp_enqueue_script('wcp-folders-custom');
2835
2836 } else {
2837 self::is_add_update_screen();
2838 }
2839
2840 if($hook == "media-new.php") {
2841 if(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
2842 wp_enqueue_style( 'folders-media', WCP_FOLDER_URL . 'assets/css/new-media.css' );
2843 $is_active = 1;
2844 $folders = -1;
2845 if (!self::check_has_valid_key()) {
2846 $is_active = 0;
2847 $folders = self::ttl_fldrs();
2848 }
2849
2850 wp_enqueue_script('wcp-folders-add-new-media', plugin_dir_url(dirname(__FILE__)) . 'assets/js/new-media.js', array('jquery'), WCP_FOLDER_VERSION);
2851 wp_localize_script( 'wcp-folders-add-new-media', 'folders_media_options', array(
2852 'terms' => self::get_terms_hierarchical('media_folder'),
2853 'taxonomy' => get_taxonomy('media_folder'),
2854 'ajax_url' => admin_url("admin-ajax.php"),
2855 'activate_url' => admin_url("admin.php?page=wcp_folders_upgrade"),
2856 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
2857 'is_key_active' => $is_active,
2858 'folders' => $folders,
2859 ));
2860 }
2861 }
2862 }
2863
2864 public function plugin_action_links($links)
2865 {
2866 array_unshift($links, '<a href="' . admin_url("admin.php?page=wcp_folders_settings") . '" >' . esc_html__('Settings', WCP_FOLDER) . '</a>');
2867 $links['need_help'] = '<a target="_blank" href="https://premio.io/help/folders/?utm_source=pluginspage" >'.__( 'Need help?', WCP_FOLDER).'</a>';
2868
2869 /* PRO link for only for FREE*/
2870 $links['pro'] = '<a class="wcp-folder-upgrade-button" href="'.admin_url("admin.php?page=wcp_folders_upgrade").'" >'.__( 'Upgrade', WCP_FOLDER).'</a>';
2871 return $links;
2872 }
2873
2874 public static function get_instance()
2875 {
2876 if (empty(self::$instance)) {
2877 /* Do not change Class name here */
2878 self::$instance = new WCP_Folders();
2879 }
2880 return self::$instance;
2881 }
2882
2883 public function check_and_set_post_type() {
2884 $options = get_option(WCP_FOLDER_VAR);
2885 $old_plugin_status = 0;
2886 $post_array = array();
2887 if (!empty($options) && is_array($options)) {
2888 foreach ($options as $key=>$val) {
2889 if (!(strpos($key, 'folders4') === false) && $old_plugin_status == 0) {
2890 $old_plugin_status = 1;
2891 }
2892 if (in_array($key, array("folders4page", "folders4post", "folders4attachment"))) {
2893 $post_array[] = str_replace("folders4", "", $key);
2894 }
2895 }
2896 } else {
2897 $post_array = array("page", "post", "attachment");
2898 }
2899 if ($old_plugin_status == 1) {
2900 update_option("folders_show_in_menu", "on");
2901 $old_plugin_var = get_option("folder_old_plugin_status");
2902 if (empty($old_plugin_var) || $old_plugin_var == null) {
2903 update_option("folder_old_plugin_status", "1");
2904 }
2905 update_option(WCP_FOLDER_VAR, $post_array);
2906 self::set_default_values_if_not_exists();
2907 }
2908 if (!empty($post_array) && get_option(WCP_FOLDER_VAR) === false) {
2909 update_option(WCP_FOLDER_VAR, $post_array);
2910 update_option("folders_show_in_menu", "off");
2911 }
2912 }
2913
2914 public static function activate()
2915 {
2916 update_option("folders_show_in_menu", "off");
2917 $option = get_option("folder_redirect_status");
2918 if($option === false) {
2919 add_option("folder_intro_box", "show");
2920 }
2921 update_option("folder_redirect_status", 1);
2922 }
2923
2924 public static function get_ttl_fldrs()
2925 {
2926 return self::ttl_fldrs();
2927 }
2928
2929 function folders_register_settings()
2930 {
2931 register_setting('folders_settings', 'folders_settings1', 'folders_settings_validate');
2932 register_setting('default_folders', 'default_folders');
2933 register_setting('customize_folders', 'customize_folders');
2934
2935 self::check_and_set_post_type();
2936
2937 $option = get_option("folder_redirect_status");
2938 if ($option == 1) {
2939 update_option("folder_redirect_status", 2);
2940 wp_redirect(admin_url("admin.php?page=wcp_folders_settings"));
2941 exit;
2942 }
2943 }
2944
2945 function wcp_manage_columns_head($defaults, $d = "")
2946 {
2947 global $typenow;
2948 $type = $typenow;
2949 if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
2950 $type = self::sanitize_options($_REQUEST['post_type']);
2951 }
2952
2953 $options = get_option("folders_settings");
2954 if (is_array($options) && in_array($type, $options)) {
2955 $columns = array(
2956 'wcp_move' => '<div class="wcp-move-multiple wcp-col" title="' . esc_attr__('Move selected items', WCP_FOLDER) . '"><span class="dashicons dashicons-move"></span><div class="wcp-items"></div></div>',
2957 ) + $defaults;
2958 return $columns;
2959 }
2960 return $defaults;
2961 }
2962
2963 function wcp_manage_columns_content($column_name, $post_ID)
2964 {
2965 $postIDs = self::$postIds;
2966 if(!is_array($postIDs)) {
2967 $postIDs = array();
2968 }
2969 if(!in_array($post_ID, $postIDs)) {
2970 $postIDs[] = $post_ID;
2971 self::$postIds = $postIDs;
2972 global $typenow;
2973 $type = $typenow;
2974 if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
2975 $type = self::sanitize_options($_REQUEST['post_type']);
2976 }
2977
2978 $options = get_option("folders_settings");
2979 if (is_array($options) && in_array($type, $options)) {
2980 if ($column_name == 'wcp_move') {
2981 $title = get_the_title();
2982 if (strlen($title) > 20) {
2983 $title = substr($title, 0, 20) . "...";
2984 }
2985 echo "<div class='wcp-move-file' data-id='{$post_ID}'><span class='wcp-move dashicons dashicons-move' data-id='{$post_ID}'></span><span class='wcp-item' data-object-id='{$post_ID}'>" . $title . "</span></div>";
2986 }
2987 }
2988 }
2989 }
2990
2991 function taxonomy_archive_exclude_children($query)
2992 {
2993 $options = get_option("folders_settings");
2994 if (!empty($options)) {
2995 $taxonomy_slugs = array();
2996 foreach ($options as $option) {
2997 $taxonomy_slugs[] = self::get_custom_post_type($option);
2998 }
2999 if (!empty($taxonomy_slugs)) {
3000 $i = 0;
3001 foreach ($query->tax_query->queries as $tax_query_item) {
3002 if (empty($taxonomy_slugs) || (isset($tax_query_item['taxonomy']) && in_array($tax_query_item['taxonomy'], $taxonomy_slugs))) {
3003 $query->tax_query->queries[$i]['include_children'] = 0;
3004 }
3005 }
3006 }
3007 }
3008 }
3009
3010 public function admin_menu()
3011 {
3012 // Add menu item for settings page
3013 $page_title = esc_attr__('Folders', WCP_FOLDER);
3014 $menu_title = esc_attr__('Folders Settings', WCP_FOLDER);
3015 $capability = 'manage_options';
3016 $menu_slug = 'wcp_folders_settings';
3017 $callback = array($this, "wcp_folders_settings");
3018 $icon_url = 'dashicons-category';
3019 $position = 99;
3020
3021 add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $position);
3022
3023 /* Do not Change Free/Pro Change for menu */
3024 add_submenu_page(
3025 $menu_slug,
3026 esc_html__('Upgrade to Pro', WCP_FOLDER),
3027 esc_html__('Upgrade to Pro', WCP_FOLDER),
3028 'manage_options',
3029 'wcp_folders_upgrade',
3030 array($this, 'wcp_folders_upgrade_or_register')
3031 );
3032
3033 self::check_and_set_post_type();
3034
3035 $show_menu = get_option("folders_show_in_menu", true);
3036 if ($show_menu == "on") {
3037 self::create_menu_for_folders();
3038 }
3039 }
3040
3041 public function wcp_folders_upgrade_or_register()
3042 {
3043 self::set_default_values_if_not_exists();
3044 include_once dirname(dirname(__FILE__)) . "/templates/admin/upgrade-to-pro.php";
3045 }
3046
3047 public function wcp_folders_settings()
3048 {
3049 self::set_default_values_if_not_exists();
3050 /* Only in Free, Get Folders update confirmation popup */
3051 $is_shown = get_option("folder_update_message");
3052 if($is_shown === false) {
3053 include_once dirname(dirname(__FILE__)) . "/templates/admin/update.php";
3054 } else {
3055 $options = get_option('folders_settings');
3056 $options = (empty($options) || !is_array($options)) ? array() : $options;
3057 $post_types = get_post_types(array('public' => true), 'objects');
3058 $terms_data = array();
3059 foreach ($post_types as $post_type) {
3060 if (in_array($post_type->name, $options)) {
3061 $term = $post_type->name;
3062 $term = self::get_custom_post_type($term);
3063 $categories = self::get_terms_hierarchical($term);
3064 $terms_data[$post_type->name] = $categories;
3065 } else {
3066 $terms_data[$post_type->name] = array();
3067 }
3068 }
3069 $fonts = self::get_font_list();
3070 include_once dirname(dirname(__FILE__)) . "/templates/admin/general-settings.php";
3071
3072 $option = get_option("folder_intro_box");
3073 if($option == "show") {
3074 include_once dirname(dirname(__FILE__)) . "/templates/admin/folder-popup.php";
3075 }
3076 }
3077 }
3078
3079 public static function get_font_list(){
3080 return array(
3081 // System fonts.
3082 'Default' => 'Default',
3083 'Arial' => 'Default',
3084 'Tahoma' => 'Default',
3085 'Verdana' => 'Default',
3086 'Helvetica' => 'Default',
3087 'Times New Roman' => 'Default',
3088 'Trebuchet MS' => 'Default',
3089 'Georgia' => 'Default',
3090
3091 // Google Fonts (last update: 23/10/2018).
3092 'ABeeZee' => 'Google Fonts',
3093 'Abel' => 'Google Fonts',
3094 'Abhaya Libre' => 'Google Fonts',
3095 'Abril Fatface' => 'Google Fonts',
3096 'Aclonica' => 'Google Fonts',
3097 'Acme' => 'Google Fonts',
3098 'Actor' => 'Google Fonts',
3099 'Adamina' => 'Google Fonts',
3100 'Advent Pro' => 'Google Fonts',
3101 'Aguafina Script' => 'Google Fonts',
3102 'Akronim' => 'Google Fonts',
3103 'Aladin' => 'Google Fonts',
3104 'Aldrich' => 'Google Fonts',
3105 'Alef' => 'Google Fonts',
3106 'Alef Hebrew' => 'Google Fonts', // Hack for Google Early Access.
3107 'Alegreya' => 'Google Fonts',
3108 'Alegreya SC' => 'Google Fonts',
3109 'Alegreya Sans' => 'Google Fonts',
3110 'Alegreya Sans SC' => 'Google Fonts',
3111 'Alex Brush' => 'Google Fonts',
3112 'Alfa Slab One' => 'Google Fonts',
3113 'Alice' => 'Google Fonts',
3114 'Alike' => 'Google Fonts',
3115 'Alike Angular' => 'Google Fonts',
3116 'Allan' => 'Google Fonts',
3117 'Allerta' => 'Google Fonts',
3118 'Allerta Stencil' => 'Google Fonts',
3119 'Allura' => 'Google Fonts',
3120 'Almendra' => 'Google Fonts',
3121 'Almendra Display' => 'Google Fonts',
3122 'Almendra SC' => 'Google Fonts',
3123 'Amarante' => 'Google Fonts',
3124 'Amaranth' => 'Google Fonts',
3125 'Amatic SC' => 'Google Fonts',
3126 'Amethysta' => 'Google Fonts',
3127 'Amiko' => 'Google Fonts',
3128 'Amiri' => 'Google Fonts',
3129 'Amita' => 'Google Fonts',
3130 'Anaheim' => 'Google Fonts',
3131 'Andada' => 'Google Fonts',
3132 'Andika' => 'Google Fonts',
3133 'Angkor' => 'Google Fonts',
3134 'Annie Use Your Telescope' => 'Google Fonts',
3135 'Anonymous Pro' => 'Google Fonts',
3136 'Antic' => 'Google Fonts',
3137 'Antic Didone' => 'Google Fonts',
3138 'Antic Slab' => 'Google Fonts',
3139 'Anton' => 'Google Fonts',
3140 'Arapey' => 'Google Fonts',
3141 'Arbutus' => 'Google Fonts',
3142 'Arbutus Slab' => 'Google Fonts',
3143 'Architects Daughter' => 'Google Fonts',
3144 'Archivo' => 'Google Fonts',
3145 'Archivo Black' => 'Google Fonts',
3146 'Archivo Narrow' => 'Google Fonts',
3147 'Aref Ruqaa' => 'Google Fonts',
3148 'Arima Madurai' => 'Google Fonts',
3149 'Arimo' => 'Google Fonts',
3150 'Arizonia' => 'Google Fonts',
3151 'Armata' => 'Google Fonts',
3152 'Arsenal' => 'Google Fonts',
3153 'Artifika' => 'Google Fonts',
3154 'Arvo' => 'Google Fonts',
3155 'Arya' => 'Google Fonts',
3156 'Asap' => 'Google Fonts',
3157 'Asap Condensed' => 'Google Fonts',
3158 'Asar' => 'Google Fonts',
3159 'Asset' => 'Google Fonts',
3160 'Assistant' => 'Google Fonts',
3161 'Astloch' => 'Google Fonts',
3162 'Asul' => 'Google Fonts',
3163 'Athiti' => 'Google Fonts',
3164 'Atma' => 'Google Fonts',
3165 'Atomic Age' => 'Google Fonts',
3166 'Aubrey' => 'Google Fonts',
3167 'Audiowide' => 'Google Fonts',
3168 'Autour One' => 'Google Fonts',
3169 'Average' => 'Google Fonts',
3170 'Average Sans' => 'Google Fonts',
3171 'Averia Gruesa Libre' => 'Google Fonts',
3172 'Averia Libre' => 'Google Fonts',
3173 'Averia Sans Libre' => 'Google Fonts',
3174 'Averia Serif Libre' => 'Google Fonts',
3175 'Bad Script' => 'Google Fonts',
3176 'Bahiana' => 'Google Fonts',
3177 'Bai Jamjuree' => 'Google Fonts',
3178 'Baloo' => 'Google Fonts',
3179 'Baloo Bhai' => 'Google Fonts',
3180 'Baloo Bhaijaan' => 'Google Fonts',
3181 'Baloo Bhaina' => 'Google Fonts',
3182 'Baloo Chettan' => 'Google Fonts',
3183 'Baloo Da' => 'Google Fonts',
3184 'Baloo Paaji' => 'Google Fonts',
3185 'Baloo Tamma' => 'Google Fonts',
3186 'Baloo Tammudu' => 'Google Fonts',
3187 'Baloo Thambi' => 'Google Fonts',
3188 'Balthazar' => 'Google Fonts',
3189 'Bangers' => 'Google Fonts',
3190 'Barlow' => 'Google Fonts',
3191 'Barlow Condensed' => 'Google Fonts',
3192 'Barlow Semi Condensed' => 'Google Fonts',
3193 'Barrio' => 'Google Fonts',
3194 'Basic' => 'Google Fonts',
3195 'Battambang' => 'Google Fonts',
3196 'Baumans' => 'Google Fonts',
3197 'Bayon' => 'Google Fonts',
3198 'Belgrano' => 'Google Fonts',
3199 'Bellefair' => 'Google Fonts',
3200 'Belleza' => 'Google Fonts',
3201 'BenchNine' => 'Google Fonts',
3202 'Bentham' => 'Google Fonts',
3203 'Berkshire Swash' => 'Google Fonts',
3204 'Bevan' => 'Google Fonts',
3205 'Bigelow Rules' => 'Google Fonts',
3206 'Bigshot One' => 'Google Fonts',
3207 'Bilbo' => 'Google Fonts',
3208 'Bilbo Swash Caps' => 'Google Fonts',
3209 'BioRhyme' => 'Google Fonts',
3210 'BioRhyme Expanded' => 'Google Fonts',
3211 'Biryani' => 'Google Fonts',
3212 'Bitter' => 'Google Fonts',
3213 'Black And White Picture' => 'Google Fonts',
3214 'Black Han Sans' => 'Google Fonts',
3215 'Black Ops One' => 'Google Fonts',
3216 'Bokor' => 'Google Fonts',
3217 'Bonbon' => 'Google Fonts',
3218 'Boogaloo' => 'Google Fonts',
3219 'Bowlby One' => 'Google Fonts',
3220 'Bowlby One SC' => 'Google Fonts',
3221 'Brawler' => 'Google Fonts',
3222 'Bree Serif' => 'Google Fonts',
3223 'Bubblegum Sans' => 'Google Fonts',
3224 'Bubbler One' => 'Google Fonts',
3225 'Buda' => 'Google Fonts',
3226 'Buenard' => 'Google Fonts',
3227 'Bungee' => 'Google Fonts',
3228 'Bungee Hairline' => 'Google Fonts',
3229 'Bungee Inline' => 'Google Fonts',
3230 'Bungee Outline' => 'Google Fonts',
3231 'Bungee Shade' => 'Google Fonts',
3232 'Butcherman' => 'Google Fonts',
3233 'Butterfly Kids' => 'Google Fonts',
3234 'Cabin' => 'Google Fonts',
3235 'Cabin Condensed' => 'Google Fonts',
3236 'Cabin Sketch' => 'Google Fonts',
3237 'Caesar Dressing' => 'Google Fonts',
3238 'Cagliostro' => 'Google Fonts',
3239 'Cairo' => 'Google Fonts',
3240 'Calligraffitti' => 'Google Fonts',
3241 'Cambay' => 'Google Fonts',
3242 'Cambo' => 'Google Fonts',
3243 'Candal' => 'Google Fonts',
3244 'Cantarell' => 'Google Fonts',
3245 'Cantata One' => 'Google Fonts',
3246 'Cantora One' => 'Google Fonts',
3247 'Capriola' => 'Google Fonts',
3248 'Cardo' => 'Google Fonts',
3249 'Carme' => 'Google Fonts',
3250 'Carrois Gothic' => 'Google Fonts',
3251 'Carrois Gothic SC' => 'Google Fonts',
3252 'Carter One' => 'Google Fonts',
3253 'Catamaran' => 'Google Fonts',
3254 'Caudex' => 'Google Fonts',
3255 'Caveat' => 'Google Fonts',
3256 'Caveat Brush' => 'Google Fonts',
3257 'Cedarville Cursive' => 'Google Fonts',
3258 'Ceviche One' => 'Google Fonts',
3259 'Chakra Petch' => 'Google Fonts',
3260 'Changa' => 'Google Fonts',
3261 'Changa One' => 'Google Fonts',
3262 'Chango' => 'Google Fonts',
3263 'Charmonman' => 'Google Fonts',
3264 'Chathura' => 'Google Fonts',
3265 'Chau Philomene One' => 'Google Fonts',
3266 'Chela One' => 'Google Fonts',
3267 'Chelsea Market' => 'Google Fonts',
3268 'Chenla' => 'Google Fonts',
3269 'Cherry Cream Soda' => 'Google Fonts',
3270 'Cherry Swash' => 'Google Fonts',
3271 'Chewy' => 'Google Fonts',
3272 'Chicle' => 'Google Fonts',
3273 'Chivo' => 'Google Fonts',
3274 'Chonburi' => 'Google Fonts',
3275 'Cinzel' => 'Google Fonts',
3276 'Cinzel Decorative' => 'Google Fonts',
3277 'Clicker Script' => 'Google Fonts',
3278 'Coda' => 'Google Fonts',
3279 'Coda Caption' => 'Google Fonts',
3280 'Codystar' => 'Google Fonts',
3281 'Coiny' => 'Google Fonts',
3282 'Combo' => 'Google Fonts',
3283 'Comfortaa' => 'Google Fonts',
3284 'Coming Soon' => 'Google Fonts',
3285 'Concert One' => 'Google Fonts',
3286 'Condiment' => 'Google Fonts',
3287 'Content' => 'Google Fonts',
3288 'Contrail One' => 'Google Fonts',
3289 'Convergence' => 'Google Fonts',
3290 'Cookie' => 'Google Fonts',
3291 'Copse' => 'Google Fonts',
3292 'Corben' => 'Google Fonts',
3293 'Cormorant' => 'Google Fonts',
3294 'Cormorant Garamond' => 'Google Fonts',
3295 'Cormorant Infant' => 'Google Fonts',
3296 'Cormorant SC' => 'Google Fonts',
3297 'Cormorant Unicase' => 'Google Fonts',
3298 'Cormorant Upright' => 'Google Fonts',
3299 'Courgette' => 'Google Fonts',
3300 'Cousine' => 'Google Fonts',
3301 'Coustard' => 'Google Fonts',
3302 'Covered By Your Grace' => 'Google Fonts',
3303 'Crafty Girls' => 'Google Fonts',
3304 'Creepster' => 'Google Fonts',
3305 'Crete Round' => 'Google Fonts',
3306 'Crimson Text' => 'Google Fonts',
3307 'Croissant One' => 'Google Fonts',
3308 'Crushed' => 'Google Fonts',
3309 'Cuprum' => 'Google Fonts',
3310 'Cute Font' => 'Google Fonts',
3311 'Cutive' => 'Google Fonts',
3312 'Cutive Mono' => 'Google Fonts',
3313 'Damion' => 'Google Fonts',
3314 'Dancing Script' => 'Google Fonts',
3315 'Dangrek' => 'Google Fonts',
3316 'David Libre' => 'Google Fonts',
3317 'Dawning of a New Day' => 'Google Fonts',
3318 'Days One' => 'Google Fonts',
3319 'Dekko' => 'Google Fonts',
3320 'Delius' => 'Google Fonts',
3321 'Delius Swash Caps' => 'Google Fonts',
3322 'Delius Unicase' => 'Google Fonts',
3323 'Della Respira' => 'Google Fonts',
3324 'Denk One' => 'Google Fonts',
3325 'Devonshire' => 'Google Fonts',
3326 'Dhurjati' => 'Google Fonts',
3327 'Didact Gothic' => 'Google Fonts',
3328 'Diplomata' => 'Google Fonts',
3329 'Diplomata SC' => 'Google Fonts',
3330 'Do Hyeon' => 'Google Fonts',
3331 'Dokdo' => 'Google Fonts',
3332 'Domine' => 'Google Fonts',
3333 'Donegal One' => 'Google Fonts',
3334 'Doppio One' => 'Google Fonts',
3335 'Dorsa' => 'Google Fonts',
3336 'Dosis' => 'Google Fonts',
3337 'Dr Sugiyama' => 'Google Fonts',
3338 'Droid Arabic Kufi' => 'Google Fonts', // Hack for Google Early Access.
3339 'Droid Arabic Naskh' => 'Google Fonts', // Hack for Google Early Access.
3340 'Duru Sans' => 'Google Fonts',
3341 'Dynalight' => 'Google Fonts',
3342 'EB Garamond' => 'Google Fonts',
3343 'Eagle Lake' => 'Google Fonts',
3344 'East Sea Dokdo' => 'Google Fonts',
3345 'Eater' => 'Google Fonts',
3346 'Economica' => 'Google Fonts',
3347 'Eczar' => 'Google Fonts',
3348 'El Messiri' => 'Google Fonts',
3349 'Electrolize' => 'Google Fonts',
3350 'Elsie' => 'Google Fonts',
3351 'Elsie Swash Caps' => 'Google Fonts',
3352 'Emblema One' => 'Google Fonts',
3353 'Emilys Candy' => 'Google Fonts',
3354 'Encode Sans' => 'Google Fonts',
3355 'Encode Sans Condensed' => 'Google Fonts',
3356 'Encode Sans Expanded' => 'Google Fonts',
3357 'Encode Sans Semi Condensed' => 'Google Fonts',
3358 'Encode Sans Semi Expanded' => 'Google Fonts',
3359 'Engagement' => 'Google Fonts',
3360 'Englebert' => 'Google Fonts',
3361 'Enriqueta' => 'Google Fonts',
3362 'Erica One' => 'Google Fonts',
3363 'Esteban' => 'Google Fonts',
3364 'Euphoria Script' => 'Google Fonts',
3365 'Ewert' => 'Google Fonts',
3366 'Exo' => 'Google Fonts',
3367 'Exo 2' => 'Google Fonts',
3368 'Expletus Sans' => 'Google Fonts',
3369 'Fahkwang' => 'Google Fonts',
3370 'Fanwood Text' => 'Google Fonts',
3371 'Farsan' => 'Google Fonts',
3372 'Fascinate' => 'Google Fonts',
3373 'Fascinate Inline' => 'Google Fonts',
3374 'Faster One' => 'Google Fonts',
3375 'Fasthand' => 'Google Fonts',
3376 'Fauna One' => 'Google Fonts',
3377 'Faustina' => 'Google Fonts',
3378 'Federant' => 'Google Fonts',
3379 'Federo' => 'Google Fonts',
3380 'Felipa' => 'Google Fonts',
3381 'Fenix' => 'Google Fonts',
3382 'Finger Paint' => 'Google Fonts',
3383 'Fira Mono' => 'Google Fonts',
3384 'Fira Sans' => 'Google Fonts',
3385 'Fira Sans Condensed' => 'Google Fonts',
3386 'Fira Sans Extra Condensed' => 'Google Fonts',
3387 'Fjalla One' => 'Google Fonts',
3388 'Fjord One' => 'Google Fonts',
3389 'Flamenco' => 'Google Fonts',
3390 'Flavors' => 'Google Fonts',
3391 'Fondamento' => 'Google Fonts',
3392 'Fontdiner Swanky' => 'Google Fonts',
3393 'Forum' => 'Google Fonts',
3394 'Francois One' => 'Google Fonts',
3395 'Frank Ruhl Libre' => 'Google Fonts',
3396 'Freckle Face' => 'Google Fonts',
3397 'Fredericka the Great' => 'Google Fonts',
3398 'Fredoka One' => 'Google Fonts',
3399 'Freehand' => 'Google Fonts',
3400 'Fresca' => 'Google Fonts',
3401 'Frijole' => 'Google Fonts',
3402 'Fruktur' => 'Google Fonts',
3403 'Fugaz One' => 'Google Fonts',
3404 'GFS Didot' => 'Google Fonts',
3405 'GFS Neohellenic' => 'Google Fonts',
3406 'Gabriela' => 'Google Fonts',
3407 'Gaegu' => 'Google Fonts',
3408 'Gafata' => 'Google Fonts',
3409 'Galada' => 'Google Fonts',
3410 'Galdeano' => 'Google Fonts',
3411 'Galindo' => 'Google Fonts',
3412 'Gamja Flower' => 'Google Fonts',
3413 'Gentium Basic' => 'Google Fonts',
3414 'Gentium Book Basic' => 'Google Fonts',
3415 'Geo' => 'Google Fonts',
3416 'Geostar' => 'Google Fonts',
3417 'Geostar Fill' => 'Google Fonts',
3418 'Germania One' => 'Google Fonts',
3419 'Gidugu' => 'Google Fonts',
3420 'Gilda Display' => 'Google Fonts',
3421 'Give You Glory' => 'Google Fonts',
3422 'Glass Antiqua' => 'Google Fonts',
3423 'Glegoo' => 'Google Fonts',
3424 'Gloria Hallelujah' => 'Google Fonts',
3425 'Goblin One' => 'Google Fonts',
3426 'Gochi Hand' => 'Google Fonts',
3427 'Gorditas' => 'Google Fonts',
3428 'Gothic A1' => 'Google Fonts',
3429 'Goudy Bookletter 1911' => 'Google Fonts',
3430 'Graduate' => 'Google Fonts',
3431 'Grand Hotel' => 'Google Fonts',
3432 'Gravitas One' => 'Google Fonts',
3433 'Great Vibes' => 'Google Fonts',
3434 'Griffy' => 'Google Fonts',
3435 'Gruppo' => 'Google Fonts',
3436 'Gudea' => 'Google Fonts',
3437 'Gugi' => 'Google Fonts',
3438 'Gurajada' => 'Google Fonts',
3439 'Habibi' => 'Google Fonts',
3440 'Halant' => 'Google Fonts',
3441 'Hammersmith One' => 'Google Fonts',
3442 'Hanalei' => 'Google Fonts',
3443 'Hanalei Fill' => 'Google Fonts',
3444 'Handlee' => 'Google Fonts',
3445 'Hanuman' => 'Google Fonts',
3446 'Happy Monkey' => 'Google Fonts',
3447 'Harmattan' => 'Google Fonts',
3448 'Headland One' => 'Google Fonts',
3449 'Heebo' => 'Google Fonts',
3450 'Henny Penny' => 'Google Fonts',
3451 'Herr Von Muellerhoff' => 'Google Fonts',
3452 'Hi Melody' => 'Google Fonts',
3453 'Hind' => 'Google Fonts',
3454 'Hind Guntur' => 'Google Fonts',
3455 'Hind Madurai' => 'Google Fonts',
3456 'Hind Siliguri' => 'Google Fonts',
3457 'Hind Vadodara' => 'Google Fonts',
3458 'Holtwood One SC' => 'Google Fonts',
3459 'Homemade Apple' => 'Google Fonts',
3460 'Homenaje' => 'Google Fonts',
3461 'IBM Plex Mono' => 'Google Fonts',
3462 'IBM Plex Sans' => 'Google Fonts',
3463 'IBM Plex Sans Condensed' => 'Google Fonts',
3464 'IBM Plex Serif' => 'Google Fonts',
3465 'IM Fell DW Pica' => 'Google Fonts',
3466 'IM Fell DW Pica SC' => 'Google Fonts',
3467 'IM Fell Double Pica' => 'Google Fonts',
3468 'IM Fell Double Pica SC' => 'Google Fonts',
3469 'IM Fell English' => 'Google Fonts',
3470 'IM Fell English SC' => 'Google Fonts',
3471 'IM Fell French Canon' => 'Google Fonts',
3472 'IM Fell French Canon SC' => 'Google Fonts',
3473 'IM Fell Great Primer' => 'Google Fonts',
3474 'IM Fell Great Primer SC' => 'Google Fonts',
3475 'Iceberg' => 'Google Fonts',
3476 'Iceland' => 'Google Fonts',
3477 'Imprima' => 'Google Fonts',
3478 'Inconsolata' => 'Google Fonts',
3479 'Inder' => 'Google Fonts',
3480 'Indie Flower' => 'Google Fonts',
3481 'Inika' => 'Google Fonts',
3482 'Inknut Antiqua' => 'Google Fonts',
3483 'Irish Grover' => 'Google Fonts',
3484 'Istok Web' => 'Google Fonts',
3485 'Italiana' => 'Google Fonts',
3486 'Italianno' => 'Google Fonts',
3487 'Itim' => 'Google Fonts',
3488 'Jacques Francois' => 'Google Fonts',
3489 'Jacques Francois Shadow' => 'Google Fonts',
3490 'Jaldi' => 'Google Fonts',
3491 'Jim Nightshade' => 'Google Fonts',
3492 'Jockey One' => 'Google Fonts',
3493 'Jolly Lodger' => 'Google Fonts',
3494 'Jomhuria' => 'Google Fonts',
3495 'Josefin Sans' => 'Google Fonts',
3496 'Josefin Slab' => 'Google Fonts',
3497 'Joti One' => 'Google Fonts',
3498 'Jua' => 'Google Fonts',
3499 'Judson' => 'Google Fonts',
3500 'Julee' => 'Google Fonts',
3501 'Julius Sans One' => 'Google Fonts',
3502 'Junge' => 'Google Fonts',
3503 'Jura' => 'Google Fonts',
3504 'Just Another Hand' => 'Google Fonts',
3505 'Just Me Again Down Here' => 'Google Fonts',
3506 'K2D' => 'Google Fonts',
3507 'Kadwa' => 'Google Fonts',
3508 'Kalam' => 'Google Fonts',
3509 'Kameron' => 'Google Fonts',
3510 'Kanit' => 'Google Fonts',
3511 'Kantumruy' => 'Google Fonts',
3512 'Karla' => 'Google Fonts',
3513 'Karma' => 'Google Fonts',
3514 'Katibeh' => 'Google Fonts',
3515 'Kaushan Script' => 'Google Fonts',
3516 'Kavivanar' => 'Google Fonts',
3517 'Kavoon' => 'Google Fonts',
3518 'Kdam Thmor' => 'Google Fonts',
3519 'Keania One' => 'Google Fonts',
3520 'Kelly Slab' => 'Google Fonts',
3521 'Kenia' => 'Google Fonts',
3522 'Khand' => 'Google Fonts',
3523 'Khmer' => 'Google Fonts',
3524 'Khula' => 'Google Fonts',
3525 'Kirang Haerang' => 'Google Fonts',
3526 'Kite One' => 'Google Fonts',
3527 'Knewave' => 'Google Fonts',
3528 'KoHo' => 'Google Fonts',
3529 'Kodchasan' => 'Google Fonts',
3530 'Kosugi' => 'Google Fonts',
3531 'Kosugi Maru' => 'Google Fonts',
3532 'Kotta One' => 'Google Fonts',
3533 'Koulen' => 'Google Fonts',
3534 'Kranky' => 'Google Fonts',
3535 'Kreon' => 'Google Fonts',
3536 'Kristi' => 'Google Fonts',
3537 'Krona One' => 'Google Fonts',
3538 'Krub' => 'Google Fonts',
3539 'Kumar One' => 'Google Fonts',
3540 'Kumar One Outline' => 'Google Fonts',
3541 'Kurale' => 'Google Fonts',
3542 'La Belle Aurore' => 'Google Fonts',
3543 'Laila' => 'Google Fonts',
3544 'Lakki Reddy' => 'Google Fonts',
3545 'Lalezar' => 'Google Fonts',
3546 'Lancelot' => 'Google Fonts',
3547 'Lateef' => 'Google Fonts',
3548 'Lato' => 'Google Fonts',
3549 'League Script' => 'Google Fonts',
3550 'Leckerli One' => 'Google Fonts',
3551 'Ledger' => 'Google Fonts',
3552 'Lekton' => 'Google Fonts',
3553 'Lemon' => 'Google Fonts',
3554 'Lemonada' => 'Google Fonts',
3555 'Libre Barcode 128' => 'Google Fonts',
3556 'Libre Barcode 128 Text' => 'Google Fonts',
3557 'Libre Barcode 39' => 'Google Fonts',
3558 'Libre Barcode 39 Extended' => 'Google Fonts',
3559 'Libre Barcode 39 Extended Text' => 'Google Fonts',
3560 'Libre Barcode 39 Text' => 'Google Fonts',
3561 'Libre Baskerville' => 'Google Fonts',
3562 'Libre Franklin' => 'Google Fonts',
3563 'Life Savers' => 'Google Fonts',
3564 'Lilita One' => 'Google Fonts',
3565 'Lily Script One' => 'Google Fonts',
3566 'Limelight' => 'Google Fonts',
3567 'Linden Hill' => 'Google Fonts',
3568 'Lobster' => 'Google Fonts',
3569 'Lobster Two' => 'Google Fonts',
3570 'Londrina Outline' => 'Google Fonts',
3571 'Londrina Shadow' => 'Google Fonts',
3572 'Londrina Sketch' => 'Google Fonts',
3573 'Londrina Solid' => 'Google Fonts',
3574 'Lora' => 'Google Fonts',
3575 'Love Ya Like A Sister' => 'Google Fonts',
3576 'Loved by the King' => 'Google Fonts',
3577 'Lovers Quarrel' => 'Google Fonts',
3578 'Luckiest Guy' => 'Google Fonts',
3579 'Lusitana' => 'Google Fonts',
3580 'Lustria' => 'Google Fonts',
3581 'M PLUS 1p' => 'Google Fonts',
3582 'M PLUS Rounded 1c' => 'Google Fonts',
3583 'Macondo' => 'Google Fonts',
3584 'Macondo Swash Caps' => 'Google Fonts',
3585 'Mada' => 'Google Fonts',
3586 'Magra' => 'Google Fonts',
3587 'Maiden Orange' => 'Google Fonts',
3588 'Maitree' => 'Google Fonts',
3589 'Mako' => 'Google Fonts',
3590 'Mali' => 'Google Fonts',
3591 'Mallanna' => 'Google Fonts',
3592 'Mandali' => 'Google Fonts',
3593 'Manuale' => 'Google Fonts',
3594 'Marcellus' => 'Google Fonts',
3595 'Marcellus SC' => 'Google Fonts',
3596 'Marck Script' => 'Google Fonts',
3597 'Margarine' => 'Google Fonts',
3598 'Markazi Text' => 'Google Fonts',
3599 'Marko One' => 'Google Fonts',
3600 'Marmelad' => 'Google Fonts',
3601 'Martel' => 'Google Fonts',
3602 'Martel Sans' => 'Google Fonts',
3603 'Marvel' => 'Google Fonts',
3604 'Mate' => 'Google Fonts',
3605 'Mate SC' => 'Google Fonts',
3606 'Maven Pro' => 'Google Fonts',
3607 'McLaren' => 'Google Fonts',
3608 'Meddon' => 'Google Fonts',
3609 'MedievalSharp' => 'Google Fonts',
3610 'Medula One' => 'Google Fonts',
3611 'Meera Inimai' => 'Google Fonts',
3612 'Megrim' => 'Google Fonts',
3613 'Meie Script' => 'Google Fonts',
3614 'Merienda' => 'Google Fonts',
3615 'Merienda One' => 'Google Fonts',
3616 'Merriweather' => 'Google Fonts',
3617 'Merriweather Sans' => 'Google Fonts',
3618 'Metal' => 'Google Fonts',
3619 'Metal Mania' => 'Google Fonts',
3620 'Metamorphous' => 'Google Fonts',
3621 'Metrophobic' => 'Google Fonts',
3622 'Michroma' => 'Google Fonts',
3623 'Milonga' => 'Google Fonts',
3624 'Miltonian' => 'Google Fonts',
3625 'Miltonian Tattoo' => 'Google Fonts',
3626 'Mina' => 'Google Fonts',
3627 'Miniver' => 'Google Fonts',
3628 'Miriam Libre' => 'Google Fonts',
3629 'Mirza' => 'Google Fonts',
3630 'Miss Fajardose' => 'Google Fonts',
3631 'Mitr' => 'Google Fonts',
3632 'Modak' => 'Google Fonts',
3633 'Modern Antiqua' => 'Google Fonts',
3634 'Mogra' => 'Google Fonts',
3635 'Molengo' => 'Google Fonts',
3636 'Molle' => 'Google Fonts',
3637 'Monda' => 'Google Fonts',
3638 'Monofett' => 'Google Fonts',
3639 'Monoton' => 'Google Fonts',
3640 'Monsieur La Doulaise' => 'Google Fonts',
3641 'Montaga' => 'Google Fonts',
3642 'Montez' => 'Google Fonts',
3643 'Montserrat' => 'Google Fonts',
3644 'Montserrat Alternates' => 'Google Fonts',
3645 'Montserrat Subrayada' => 'Google Fonts',
3646 'Moul' => 'Google Fonts',
3647 'Moulpali' => 'Google Fonts',
3648 'Mountains of Christmas' => 'Google Fonts',
3649 'Mouse Memoirs' => 'Google Fonts',
3650 'Mr Bedfort' => 'Google Fonts',
3651 'Mr Dafoe' => 'Google Fonts',
3652 'Mr De Haviland' => 'Google Fonts',
3653 'Mrs Saint Delafield' => 'Google Fonts',
3654 'Mrs Sheppards' => 'Google Fonts',
3655 'Mukta' => 'Google Fonts',
3656 'Mukta Mahee' => 'Google Fonts',
3657 'Mukta Malar' => 'Google Fonts',
3658 'Mukta Vaani' => 'Google Fonts',
3659 'Muli' => 'Google Fonts',
3660 'Mystery Quest' => 'Google Fonts',
3661 'NTR' => 'Google Fonts',
3662 'Nanum Brush Script' => 'Google Fonts',
3663 'Nanum Gothic' => 'Google Fonts',
3664 'Nanum Gothic Coding' => 'Google Fonts',
3665 'Nanum Myeongjo' => 'Google Fonts',
3666 'Nanum Pen Script' => 'Google Fonts',
3667 'Neucha' => 'Google Fonts',
3668 'Neuton' => 'Google Fonts',
3669 'New Rocker' => 'Google Fonts',
3670 'News Cycle' => 'Google Fonts',
3671 'Niconne' => 'Google Fonts',
3672 'Niramit' => 'Google Fonts',
3673 'Nixie One' => 'Google Fonts',
3674 'Nobile' => 'Google Fonts',
3675 'Nokora' => 'Google Fonts',
3676 'Norican' => 'Google Fonts',
3677 'Nosifer' => 'Google Fonts',
3678 'Notable' => 'Google Fonts',
3679 'Nothing You Could Do' => 'Google Fonts',
3680 'Noticia Text' => 'Google Fonts',
3681 'Noto Kufi Arabic' => 'Google Fonts', // Hack for Google Early Access.
3682 'Noto Naskh Arabic' => 'Google Fonts', // Hack for Google Early Access.
3683 'Noto Sans' => 'Google Fonts',
3684 'Noto Sans Hebrew' => 'Google Fonts', // Hack for Google Early Access.
3685 'Noto Sans JP' => 'Google Fonts',
3686 'Noto Sans KR' => 'Google Fonts',
3687 'Noto Serif' => 'Google Fonts',
3688 'Noto Serif JP' => 'Google Fonts',
3689 'Noto Serif KR' => 'Google Fonts',
3690 'Nova Cut' => 'Google Fonts',
3691 'Nova Flat' => 'Google Fonts',
3692 'Nova Mono' => 'Google Fonts',
3693 'Nova Oval' => 'Google Fonts',
3694 'Nova Round' => 'Google Fonts',
3695 'Nova Script' => 'Google Fonts',
3696 'Nova Slim' => 'Google Fonts',
3697 'Nova Square' => 'Google Fonts',
3698 'Numans' => 'Google Fonts',
3699 'Nunito' => 'Google Fonts',
3700 'Nunito Sans' => 'Google Fonts',
3701 'Odor Mean Chey' => 'Google Fonts',
3702 'Offside' => 'Google Fonts',
3703 'Old Standard TT' => 'Google Fonts',
3704 'Oldenburg' => 'Google Fonts',
3705 'Oleo Script' => 'Google Fonts',
3706 'Oleo Script Swash Caps' => 'Google Fonts',
3707 'Open Sans' => 'Google Fonts',
3708 'Open Sans Condensed' => 'Google Fonts',
3709 'Open Sans Hebrew' => 'Google Fonts', // Hack for Google Early Access.
3710 'Open Sans Hebrew Condensed' => 'Google Fonts', // Hack for Google Early Access.
3711 'Oranienbaum' => 'Google Fonts',
3712 'Orbitron' => 'Google Fonts',
3713 'Oregano' => 'Google Fonts',
3714 'Orienta' => 'Google Fonts',
3715 'Original Surfer' => 'Google Fonts',
3716 'Oswald' => 'Google Fonts',
3717 'Over the Rainbow' => 'Google Fonts',
3718 'Overlock' => 'Google Fonts',
3719 'Overlock SC' => 'Google Fonts',
3720 'Overpass' => 'Google Fonts',
3721 'Overpass Mono' => 'Google Fonts',
3722 'Ovo' => 'Google Fonts',
3723 'Oxygen' => 'Google Fonts',
3724 'Oxygen Mono' => 'Google Fonts',
3725 'PT Mono' => 'Google Fonts',
3726 'PT Sans' => 'Google Fonts',
3727 'PT Sans Caption' => 'Google Fonts',
3728 'PT Sans Narrow' => 'Google Fonts',
3729 'PT Serif' => 'Google Fonts',
3730 'PT Serif Caption' => 'Google Fonts',
3731 'Pacifico' => 'Google Fonts',
3732 'Padauk' => 'Google Fonts',
3733 'Palanquin' => 'Google Fonts',
3734 'Palanquin Dark' => 'Google Fonts',
3735 'Pangolin' => 'Google Fonts',
3736 'Paprika' => 'Google Fonts',
3737 'Parisienne' => 'Google Fonts',
3738 'Passero One' => 'Google Fonts',
3739 'Passion One' => 'Google Fonts',
3740 'Pathway Gothic One' => 'Google Fonts',
3741 'Patrick Hand' => 'Google Fonts',
3742 'Patrick Hand SC' => 'Google Fonts',
3743 'Pattaya' => 'Google Fonts',
3744 'Patua One' => 'Google Fonts',
3745 'Pavanam' => 'Google Fonts',
3746 'Paytone One' => 'Google Fonts',
3747 'Peddana' => 'Google Fonts',
3748 'Peralta' => 'Google Fonts',
3749 'Permanent Marker' => 'Google Fonts',
3750 'Petit Formal Script' => 'Google Fonts',
3751 'Petrona' => 'Google Fonts',
3752 'Philosopher' => 'Google Fonts',
3753 'Piedra' => 'Google Fonts',
3754 'Pinyon Script' => 'Google Fonts',
3755 'Pirata One' => 'Google Fonts',
3756 'Plaster' => 'Google Fonts',
3757 'Play' => 'Google Fonts',
3758 'Playball' => 'Google Fonts',
3759 'Playfair Display' => 'Google Fonts',
3760 'Playfair Display SC' => 'Google Fonts',
3761 'Podkova' => 'Google Fonts',
3762 'Poiret One' => 'Google Fonts',
3763 'Poller One' => 'Google Fonts',
3764 'Poly' => 'Google Fonts',
3765 'Pompiere' => 'Google Fonts',
3766 'Pontano Sans' => 'Google Fonts',
3767 'Poor Story' => 'Google Fonts',
3768 'Poppins' => 'Google Fonts',
3769 'Port Lligat Sans' => 'Google Fonts',
3770 'Port Lligat Slab' => 'Google Fonts',
3771 'Pragati Narrow' => 'Google Fonts',
3772 'Prata' => 'Google Fonts',
3773 'Preahvihear' => 'Google Fonts',
3774 'Press Start 2P' => 'Google Fonts',
3775 'Pridi' => 'Google Fonts',
3776 'Princess Sofia' => 'Google Fonts',
3777 'Prociono' => 'Google Fonts',
3778 'Prompt' => 'Google Fonts',
3779 'Prosto One' => 'Google Fonts',
3780 'Proza Libre' => 'Google Fonts',
3781 'Puritan' => 'Google Fonts',
3782 'Purple Purse' => 'Google Fonts',
3783 'Quando' => 'Google Fonts',
3784 'Quantico' => 'Google Fonts',
3785 'Quattrocento' => 'Google Fonts',
3786 'Quattrocento Sans' => 'Google Fonts',
3787 'Questrial' => 'Google Fonts',
3788 'Quicksand' => 'Google Fonts',
3789 'Quintessential' => 'Google Fonts',
3790 'Qwigley' => 'Google Fonts',
3791 'Racing Sans One' => 'Google Fonts',
3792 'Radley' => 'Google Fonts',
3793 'Rajdhani' => 'Google Fonts',
3794 'Rakkas' => 'Google Fonts',
3795 'Raleway' => 'Google Fonts',
3796 'Raleway Dots' => 'Google Fonts',
3797 'Ramabhadra' => 'Google Fonts',
3798 'Ramaraja' => 'Google Fonts',
3799 'Rambla' => 'Google Fonts',
3800 'Rammetto One' => 'Google Fonts',
3801 'Ranchers' => 'Google Fonts',
3802 'Rancho' => 'Google Fonts',
3803 'Ranga' => 'Google Fonts',
3804 'Rasa' => 'Google Fonts',
3805 'Rationale' => 'Google Fonts',
3806 'Ravi Prakash' => 'Google Fonts',
3807 'Redressed' => 'Google Fonts',
3808 'Reem Kufi' => 'Google Fonts',
3809 'Reenie Beanie' => 'Google Fonts',
3810 'Revalia' => 'Google Fonts',
3811 'Rhodium Libre' => 'Google Fonts',
3812 'Ribeye' => 'Google Fonts',
3813 'Ribeye Marrow' => 'Google Fonts',
3814 'Righteous' => 'Google Fonts',
3815 'Risque' => 'Google Fonts',
3816 'Roboto' => 'Google Fonts',
3817 'Roboto Condensed' => 'Google Fonts',
3818 'Roboto Mono' => 'Google Fonts',
3819 'Roboto Slab' => 'Google Fonts',
3820 'Rochester' => 'Google Fonts',
3821 'Rock Salt' => 'Google Fonts',
3822 'Rokkitt' => 'Google Fonts',
3823 'Romanesco' => 'Google Fonts',
3824 'Ropa Sans' => 'Google Fonts',
3825 'Rosario' => 'Google Fonts',
3826 'Rosarivo' => 'Google Fonts',
3827 'Rouge Script' => 'Google Fonts',
3828 'Rozha One' => 'Google Fonts',
3829 'Rubik' => 'Google Fonts',
3830 'Rubik Mono One' => 'Google Fonts',
3831 'Ruda' => 'Google Fonts',
3832 'Rufina' => 'Google Fonts',
3833 'Ruge Boogie' => 'Google Fonts',
3834 'Ruluko' => 'Google Fonts',
3835 'Rum Raisin' => 'Google Fonts',
3836 'Ruslan Display' => 'Google Fonts',
3837 'Russo One' => 'Google Fonts',
3838 'Ruthie' => 'Google Fonts',
3839 'Rye' => 'Google Fonts',
3840 'Sacramento' => 'Google Fonts',
3841 'Sahitya' => 'Google Fonts',
3842 'Sail' => 'Google Fonts',
3843 'Saira' => 'Google Fonts',
3844 'Saira Condensed' => 'Google Fonts',
3845 'Saira Extra Condensed' => 'Google Fonts',
3846 'Saira Semi Condensed' => 'Google Fonts',
3847 'Salsa' => 'Google Fonts',
3848 'Sanchez' => 'Google Fonts',
3849 'Sancreek' => 'Google Fonts',
3850 'Sansita' => 'Google Fonts',
3851 'Sarala' => 'Google Fonts',
3852 'Sarina' => 'Google Fonts',
3853 'Sarpanch' => 'Google Fonts',
3854 'Satisfy' => 'Google Fonts',
3855 'Sawarabi Gothic' => 'Google Fonts',
3856 'Sawarabi Mincho' => 'Google Fonts',
3857 'Scada' => 'Google Fonts',
3858 'Scheherazade' => 'Google Fonts',
3859 'Schoolbell' => 'Google Fonts',
3860 'Scope One' => 'Google Fonts',
3861 'Seaweed Script' => 'Google Fonts',
3862 'Secular One' => 'Google Fonts',
3863 'Sedgwick Ave' => 'Google Fonts',
3864 'Sedgwick Ave Display' => 'Google Fonts',
3865 'Sevillana' => 'Google Fonts',
3866 'Seymour One' => 'Google Fonts',
3867 'Shadows Into Light' => 'Google Fonts',
3868 'Shadows Into Light Two' => 'Google Fonts',
3869 'Shanti' => 'Google Fonts',
3870 'Share' => 'Google Fonts',
3871 'Share Tech' => 'Google Fonts',
3872 'Share Tech Mono' => 'Google Fonts',
3873 'Shojumaru' => 'Google Fonts',
3874 'Short Stack' => 'Google Fonts',
3875 'Shrikhand' => 'Google Fonts',
3876 'Siemreap' => 'Google Fonts',
3877 'Sigmar One' => 'Google Fonts',
3878 'Signika' => 'Google Fonts',
3879 'Signika Negative' => 'Google Fonts',
3880 'Simonetta' => 'Google Fonts',
3881 'Sintony' => 'Google Fonts',
3882 'Sirin Stencil' => 'Google Fonts',
3883 'Six Caps' => 'Google Fonts',
3884 'Skranji' => 'Google Fonts',
3885 'Slabo 13px' => 'Google Fonts',
3886 'Slabo 27px' => 'Google Fonts',
3887 'Slackey' => 'Google Fonts',
3888 'Smokum' => 'Google Fonts',
3889 'Smythe' => 'Google Fonts',
3890 'Sniglet' => 'Google Fonts',
3891 'Snippet' => 'Google Fonts',
3892 'Snowburst One' => 'Google Fonts',
3893 'Sofadi One' => 'Google Fonts',
3894 'Sofia' => 'Google Fonts',
3895 'Song Myung' => 'Google Fonts',
3896 'Sonsie One' => 'Google Fonts',
3897 'Sorts Mill Goudy' => 'Google Fonts',
3898 'Source Code Pro' => 'Google Fonts',
3899 'Source Sans Pro' => 'Google Fonts',
3900 'Source Serif Pro' => 'Google Fonts',
3901 'Space Mono' => 'Google Fonts',
3902 'Special Elite' => 'Google Fonts',
3903 'Spectral' => 'Google Fonts',
3904 'Spectral SC' => 'Google Fonts',
3905 'Spicy Rice' => 'Google Fonts',
3906 'Spinnaker' => 'Google Fonts',
3907 'Spirax' => 'Google Fonts',
3908 'Squada One' => 'Google Fonts',
3909 'Sree Krushnadevaraya' => 'Google Fonts',
3910 'Sriracha' => 'Google Fonts',
3911 'Srisakdi' => 'Google Fonts',
3912 'Stalemate' => 'Google Fonts',
3913 'Stalinist One' => 'Google Fonts',
3914 'Stardos Stencil' => 'Google Fonts',
3915 'Stint Ultra Condensed' => 'Google Fonts',
3916 'Stint Ultra Expanded' => 'Google Fonts',
3917 'Stoke' => 'Google Fonts',
3918 'Strait' => 'Google Fonts',
3919 'Stylish' => 'Google Fonts',
3920 'Sue Ellen Francisco' => 'Google Fonts',
3921 'Suez One' => 'Google Fonts',
3922 'Sumana' => 'Google Fonts',
3923 'Sunflower' => 'Google Fonts',
3924 'Sunshiney' => 'Google Fonts',
3925 'Supermercado One' => 'Google Fonts',
3926 'Sura' => 'Google Fonts',
3927 'Suranna' => 'Google Fonts',
3928 'Suravaram' => 'Google Fonts',
3929 'Suwannaphum' => 'Google Fonts',
3930 'Swanky and Moo Moo' => 'Google Fonts',
3931 'Syncopate' => 'Google Fonts',
3932 'Tajawal' => 'Google Fonts',
3933 'Tangerine' => 'Google Fonts',
3934 'Taprom' => 'Google Fonts',
3935 'Tauri' => 'Google Fonts',
3936 'Taviraj' => 'Google Fonts',
3937 'Teko' => 'Google Fonts',
3938 'Telex' => 'Google Fonts',
3939 'Tenali Ramakrishna' => 'Google Fonts',
3940 'Tenor Sans' => 'Google Fonts',
3941 'Text Me One' => 'Google Fonts',
3942 'The Girl Next Door' => 'Google Fonts',
3943 'Tienne' => 'Google Fonts',
3944 'Tillana' => 'Google Fonts',
3945 'Timmana' => 'Google Fonts',
3946 'Tinos' => 'Google Fonts',
3947 'Titan One' => 'Google Fonts',
3948 'Titillium Web' => 'Google Fonts',
3949 'Trade Winds' => 'Google Fonts',
3950 'Trirong' => 'Google Fonts',
3951 'Trocchi' => 'Google Fonts',
3952 'Trochut' => 'Google Fonts',
3953 'Trykker' => 'Google Fonts',
3954 'Tulpen One' => 'Google Fonts',
3955 'Ubuntu' => 'Google Fonts',
3956 'Ubuntu Condensed' => 'Google Fonts',
3957 'Ubuntu Mono' => 'Google Fonts',
3958 'Ultra' => 'Google Fonts',
3959 'Uncial Antiqua' => 'Google Fonts',
3960 'Underdog' => 'Google Fonts',
3961 'Unica One' => 'Google Fonts',
3962 'UnifrakturCook' => 'Google Fonts',
3963 'UnifrakturMaguntia' => 'Google Fonts',
3964 'Unkempt' => 'Google Fonts',
3965 'Unlock' => 'Google Fonts',
3966 'Unna' => 'Google Fonts',
3967 'VT323' => 'Google Fonts',
3968 'Vampiro One' => 'Google Fonts',
3969 'Varela' => 'Google Fonts',
3970 'Varela Round' => 'Google Fonts',
3971 'Vast Shadow' => 'Google Fonts',
3972 'Vesper Libre' => 'Google Fonts',
3973 'Vibur' => 'Google Fonts',
3974 'Vidaloka' => 'Google Fonts',
3975 'Viga' => 'Google Fonts',
3976 'Voces' => 'Google Fonts',
3977 'Volkhov' => 'Google Fonts',
3978 'Vollkorn' => 'Google Fonts',
3979 'Vollkorn SC' => 'Google Fonts',
3980 'Voltaire' => 'Google Fonts',
3981 'Waiting for the Sunrise' => 'Google Fonts',
3982 'Wallpoet' => 'Google Fonts',
3983 'Walter Turncoat' => 'Google Fonts',
3984 'Warnes' => 'Google Fonts',
3985 'Wellfleet' => 'Google Fonts',
3986 'Wendy One' => 'Google Fonts',
3987 'Wire One' => 'Google Fonts',
3988 'Work Sans' => 'Google Fonts',
3989 'Yanone Kaffeesatz' => 'Google Fonts',
3990 'Yantramanav' => 'Google Fonts',
3991 'Yatra One' => 'Google Fonts',
3992 'Yellowtail' => 'Google Fonts',
3993 'Yeon Sung' => 'Google Fonts',
3994 'Yeseva One' => 'Google Fonts',
3995 'Yesteryear' => 'Google Fonts',
3996 'Yrsa' => 'Google Fonts',
3997 'Zeyada' => 'Google Fonts',
3998 'Zilla Slab' => 'Google Fonts',
3999 'Zilla Slab Highlight' => 'Google Fonts',
4000 );
4001 }
4002
4003 public function set_default_values_if_not_exists()
4004 {
4005 $options = get_option(WCP_FOLDER_VAR);
4006 $options = empty($options) || !is_array($options) ? array() : $options;
4007 foreach ($options as $option) {
4008 $post_type = self::get_custom_post_type($option);
4009 $terms = get_terms($post_type, array(
4010 'hide_empty' => false,
4011 )
4012 );
4013 if (!empty($terms)) {
4014 foreach ($terms as $term) {
4015 $order = get_term_meta($term->term_id, "wcp_custom_order", true);
4016 if (empty($order) || $order == null) {
4017 update_term_meta($term->term_id, "wcp_custom_order", "1");
4018 }
4019 }
4020 }
4021 }
4022 }
4023
4024 /* Free and Pro major changes */
4025 public function update_popup_status() {
4026 if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'folder_update_popup_status')) {
4027 update_option("folder_intro_box", "hide");
4028 }
4029 echo esc_attr("1");
4030 die;
4031 }
4032
4033 public function check_has_valid_key()
4034 {
4035 /* Free/Pro: checking for key, for Free return 0, for Pro check for Key */
4036 return 0;
4037 }
4038
4039 public function get_license_key_information($licenseKey)
4040 {
4041 return array();
4042 }
4043
4044 public function get_license_key_data($licenseKey = '')
4045 {
4046 return array();
4047 }
4048
4049 public function check_for_license_key()
4050 {
4051 return false;
4052 }
4053 }