PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / 2.6
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager v2.6
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 5 years ago form.class.php 6 years ago plugin.updates.php 6 years ago tree.class.php 5 years ago
folders.class.php
4087 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_taxonomy_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 then 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-tree', WCP_FOLDER_URL . 'assets/js/jstree.min.js', array(), WCP_FOLDER_VERSION, true);
953 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);
954 wp_localize_script('folders-media', 'folders_media_options', array(
955 'terms' => self::get_terms_hierarchical('media_folder'),
956 'taxonomy' => get_taxonomy('media_folder'),
957 'ajax_url' => admin_url("admin-ajax.php"),
958 'media_page_url' => admin_url("upload.php"),
959 'activate_url' => admin_url("admin.php?page=wcp_folders_register"),
960 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
961 'is_key_active' => $is_active,
962 'folders' => $folders,
963 'upgrade_url' => admin_url('admin.php?page=wcp_folders_upgrade'),
964 'post_type' => 'attachment',
965 'page_url' => $admin_url,
966 'current_url' => "",
967 'ajax_image' => plugin_dir_url(dirname(__FILE__)) . "assets/images/ajax-loader.gif",
968 'register_url' => "",
969 'isRTL' => $is_rtl,
970 'can_manage_folder' => $can_manage_folder,
971 'folder_width' => $width,
972 'taxonomy_status' => $taxonomy_status,
973 'selected_taxonomy' => $selected_taxonomy,
974 'show_in_page' => $show_in_page,
975 'svg_file' => WCP_FOLDER_URL . 'assets/images/pin.png',
976 ));
977 /* Free/Pro URL Change */
978 wp_enqueue_style('folders-jstree', WCP_FOLDER_URL . 'assets/css/jstree.min.css', array(), WCP_FOLDER_VERSION);
979 wp_enqueue_style('folder-folders', WCP_FOLDER_URL . 'assets/css/folders.min.css', array(), WCP_FOLDER_VERSION);
980 wp_enqueue_style('folders-media', WCP_FOLDER_URL . 'assets/css/page-post-media.min.css', array(), WCP_FOLDER_VERSION);
981 wp_enqueue_style('folder-icon', WCP_FOLDER_URL . 'assets/css/folder-icon.css', array(), WCP_FOLDER_VERSION);
982 $width = 275;
983 $width = $width - 40;
984 $string = "";
985 $css_text = "";
986 $css_text .= '.ui-state-highlight { background: transparent; border: dashed 1px #0073AA; width:150px; height: 25px !important; }';
987 $customize_folders = get_option('customize_folders');
988 if (isset($customize_folders['new_folder_color']) && !empty($customize_folders['new_folder_color'])) {
989 $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']) . "}";
990 $css_text .= ".wcp-hide-show-buttons .toggle-buttons { background-color: " . esc_attr($customize_folders['new_folder_color']) . "; }";
991 $css_text .= ".folders-toggle-button span { background-color: " . esc_attr($customize_folders['new_folder_color']) . "; }";
992 $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}";
993 }
994 if (isset($customize_folders['folder_bg_color']) && !empty($customize_folders['folder_bg_color'])) {
995 $rgbColor = self::hexToRgb($customize_folders['folder_bg_color']);
996 $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked), body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked):hover { background: rgba(".$rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08) !important; color: #333333;}";
997 $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked, body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked:not(.jstree-clicked):focus, #custom-scroll-menu .jstree-clicked, #custom-scroll-menu .jstree-clicked:hover { background: ".$customize_folders['folder_bg_color']." !important; color: #ffffff !important; }";
998 $css_text .= "#custom-scroll-menu .jstree-hovered.wcp-drop-hover, #custom-scroll-menu .jstree-hovered.wcp-drop-hover:hover, #custom-scroll-menu .jstree-clicked.wcp-drop-hover, #custom-scroll-menu .jstree-clicked.wcp-drop-hover:hover, body #custom-scroll-menu *.drag-in >, body #custom-scroll-menu *.drag-in > a:hover { background: ".$customize_folders['folder_bg_color']." !important; color: #ffffff !important; }";
999 $css_text .= ".drag-bot > a { border-bottom: solid 2px ".$customize_folders['folder_bg_color']."}";
1000 $css_text .= ".drag-up > a { border-top: solid 2px ".$customize_folders['folder_bg_color']."}";
1001 $css_text .= "body:not(.no-hover-css) #custom-scroll-menu *.drag-in > a.jstree-hovered, body:not(.no-hover-css) #custom-scroll-menu *.drag-in > a.jstree-hovered:hover {background: ".$customize_folders['folder_bg_color']." !important; color: #fff !important;}";
1002 $css_text .= ".orange-bg > span, .jstree-clicked, .header-posts a.active-item, .un-categorised-items.active-item, .sticky-folders ul li a.active-item { background-color: " . esc_attr($customize_folders['folder_bg_color']) . " !important; color: #ffffff !important; }";
1003 $css_text .= "body:not(.no-hover-css) .wcp-container .route .title:hover, body:not(.no-hover-css) .header-posts a:hover, body:not(.no-hover-css) .un-categorised-items:hover, body:not(.no-hover-css) .sticky-folders ul li a:hover { background: rgba(".esc_attr($rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08")."); color: #333333;}";
1004 //$css_text .= "body:not(.no-hover-css) .wcp-container .route .title:hover, .header-posts a:hover, .un-categorised-items.active-item, .un-categorised-items:hover, .sticky-folders ul li a:hover {background: rgba(" . esc_attr($rgbColor['r'] . "," . $rgbColor['g'] . "," . $rgbColor['b'] . ", 0.08") . "); color:#444444;}";
1005 $css_text .= ".wcp-drop-hover {background-color: " . esc_attr($customize_folders['folder_bg_color']) . " !important; color: #ffffff; }";
1006 $css_text .= "#custom-menu .route .nav-icon .wcp-icon {color: " . esc_attr($customize_folders['folder_bg_color']) . " !important;}";
1007 $css_text .= ".mCS-3d.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar {background-color: " . esc_attr($customize_folders['folder_bg_color']) . " !important;}";
1008 $css_text .= "body:not(.no-hover-css) .jstree-hovered {background: rgba(" . esc_attr($rgbColor['r'] . "," . $rgbColor['g'] . "," . $rgbColor['b'] . ", 0.08") . "}";
1009 $css_text .= ".jstree-default .jstree-clicked {" . esc_attr($customize_folders['folder_bg_color']) . "}";
1010 }
1011 if (isset($customize_folders['bulk_organize_button_color']) && !empty($customize_folders['bulk_organize_button_color'])) {
1012 $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']) . "; }";
1013 $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']) . "; }";
1014 }
1015 $font_family = "";
1016 if (isset($customize_folders['folder_font']) && !empty($customize_folders['folder_font'])) {
1017 $folder_fonts = self::get_font_list();
1018 $font_family = $customize_folders['folder_font'];
1019 if (isset($folder_fonts[$font_family])) {
1020 $css_text .= ".wcp-container, .folder-popup-form { font-family: " . esc_attr($font_family) . " !important; }";
1021 }
1022 if ($folder_fonts[$font_family] == "Default") {
1023 $font_family = "";
1024 }
1025 }
1026 if (isset($customize_folders['folder_size']) && !empty($customize_folders['folder_size'])) {
1027 $css_text .= ".wcp-container .route span.title-text, .header-posts a, .un-categorised-items a, .sticky-title { font-size: " . esc_attr($customize_folders['folder_size']) . "px; }";
1028 }
1029 if (!empty($font_family)) {
1030 wp_enqueue_style('custom-google-fonts', 'https://fonts.googleapis.com/css?family=' . urlencode($font_family), false);
1031 }
1032 wp_add_inline_style('folders-media', $css_text);
1033 }
1034 }
1035 }
1036
1037 public function get_terms_hierarchical( $taxonomy ) {
1038 // $terms = get_terms( array(
1039 // 'taxonomy' => $taxonomy,
1040 // 'hide_empty' => false,
1041 // 'parent' => 0,
1042 // 'orderby' => 'meta_value_num',
1043 // 'order' => 'ASC',
1044 // 'update_count_callback' => '_update_generic_term_count',
1045 // 'meta_query' => [[
1046 // 'key' => 'wcp_custom_order',
1047 // 'type' => 'NUMERIC',
1048 // ]]
1049 // ) );
1050 //
1051 // if ( empty( $terms ) ) {
1052 // return false;
1053 // }
1054 //
1055 // $hierarchy = _get_term_hierarchy( $taxonomy );
1056 //
1057 // $hierarchical_terms = array();
1058 // if(!empty($terms)) {
1059 // foreach ($terms as $term) {
1060 // if(isset($term->term_id)) {
1061 // $hierarchical_terms[] = $term;
1062 // $hierarchical_terms = self::add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $term->term_id, 1);
1063 // }
1064 // }
1065 // }
1066 //
1067 // return $hierarchical_terms;
1068 $terms = get_terms( array(
1069 'taxonomy' => $taxonomy,
1070 'hide_empty' => false,
1071 'parent' => 0,
1072 'orderby' => 'meta_value_num',
1073 'order' => 'ASC',
1074 'hierarchical' => false,
1075 'update_count_callback' => '_update_generic_term_count',
1076 'meta_query' => [[
1077 'key' => 'wcp_custom_order',
1078 'type' => 'NUMERIC',
1079 ]]
1080 ));
1081 $hierarchical_terms = array();
1082 if(!empty($terms)) {
1083 foreach ($terms as $term) {
1084 if(!empty($term) && isset($term->term_id)) {
1085 $term->term_name = $term->name;
1086 $hierarchical_terms[] = $term;
1087 $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, "-");
1088 }
1089 }
1090 }
1091 return $hierarchical_terms;
1092 }
1093
1094 public static function get_child_terms($taxonomy, $hierarchical_terms, $term_id, $separator = "-") {
1095 $terms = get_terms( array(
1096 'taxonomy' => $taxonomy,
1097 'hide_empty' => false,
1098 'parent' => $term_id,
1099 'orderby' => 'meta_value_num',
1100 'order' => 'ASC',
1101 'hierarchical' => false,
1102 'update_count_callback' => '_update_generic_term_count',
1103 'meta_query' => [[
1104 'key' => 'wcp_custom_order',
1105 'type' => 'NUMERIC',
1106 ]]
1107 ));
1108 if(!empty($terms)) {
1109 foreach ($terms as $term) {
1110 if(isset($term->name)) {
1111 $term->name = $separator . " " . $term->name;
1112 $term->term_name = trim($term->name, "-");
1113 $hierarchical_terms[] = $term;
1114 $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, $separator . "-");
1115 }
1116 }
1117 }
1118
1119 return $hierarchical_terms;
1120 }
1121
1122 private function add_child_terms_recursive( $taxonomy, $hierarchical_terms, $hierarchy, $current_term_id, $current_depth ) {
1123
1124 if ( ! isset( $hierarchy[ $current_term_id ] ) ) {
1125 return $hierarchical_terms;
1126 }
1127
1128 foreach ( $hierarchy[ $current_term_id ] as $child_term_id ) {
1129
1130 $child_term = get_term( $child_term_id, $taxonomy );
1131
1132 $child_term->name = str_pad( '', $current_depth, '-', STR_PAD_LEFT ) . ' ' . $child_term->name;
1133
1134 $hierarchical_terms[] = $child_term;
1135
1136 $hierarchical_terms = self::add_child_terms_recursive( $taxonomy, $hierarchical_terms, $hierarchy, $child_term_id, ( $current_depth + 1 ) );
1137 }
1138
1139 return $hierarchical_terms;
1140 }
1141
1142 public function filter_attachments_list( $query ) {
1143
1144 if ( ! isset( $query->query['post_type'] ) ) {
1145 return $query;
1146 }
1147
1148 if ( is_array( $query->query['post_type'] ) && ! in_array( 'attachment', $query->query['post_type'] ) ) {
1149 return $query;
1150 }
1151 if ( ! is_array( $query->query['post_type'] ) && strpos( $query->query['post_type'], 'attachment' ) === false ) {
1152 return $query;
1153 }
1154
1155 if ( ! isset( $_REQUEST['media_folder'] ) ) {
1156 return $query;
1157 }
1158
1159 $term = sanitize_text_field(wp_unslash($_REQUEST['media_folder']));
1160 if ( $term != "-1" ) {
1161 return $query;
1162 }
1163
1164 unset( $query->query_vars['media_folder'] );
1165
1166 $tax_query = array(
1167 'taxonomy' => 'media_folder',
1168 'operator' => 'NOT EXISTS',
1169 );
1170
1171 $query->set( 'tax_query', array( $tax_query ) );
1172 $query->tax_query = new WP_Tax_Query( array( $tax_query ) );
1173
1174 $query = apply_filters( 'media_library_organizer_media_filter_attachments', $query, $_REQUEST );
1175
1176 return $query;
1177
1178 }
1179
1180 public function output_list_table_filters( $post_type, $view_name )
1181 {
1182 if ($post_type != 'attachment') {
1183 return;
1184 }
1185
1186 if ($view_name != 'bar') {
1187 return;
1188 }
1189
1190 $current_term = false;
1191 if ( isset( $_REQUEST['media_folder'] ) ) {
1192 $current_term = sanitize_text_field($_REQUEST['media_folder']);
1193 }
1194
1195 wp_dropdown_categories( array(
1196 'show_option_all' => esc_attr__( 'All Folders', WCP_FOLDER),
1197 'show_option_none' => esc_attr__( '(Unassigned)', WCP_FOLDER),
1198 'option_none_value' => -1,
1199 'orderby' => 'meta_value_num',
1200 'order' => 'ASC',
1201 'show_count' => true,
1202 'hide_empty' => false,
1203 'update_count_callback' => '_update_generic_term_count',
1204 'echo' => true,
1205 'selected' => $current_term,
1206 'hierarchical' => true,
1207 'name' => 'media_folder',
1208 'id' => '',
1209 'class' => '',
1210 'taxonomy' => 'media_folder',
1211 'value_field' => 'slug',
1212 'meta_query' => [[
1213 'key' => 'wcp_custom_order',
1214 'type' => 'NUMERIC',
1215 ]]
1216 ) );
1217
1218 }
1219
1220
1221 function new_to_auto_draft($post) {
1222
1223 $post_type = $post->post_type;
1224
1225 if(self::is_for_this_post_type($post_type) && !isset($_REQUEST["folder_for_media"])) {
1226
1227 $post_type = self::get_custom_post_type($post_type);
1228 $selected_folder = get_option("selected_{$post_type}_folder");
1229
1230 if($selected_folder != null && !empty($selected_folder)) {
1231 $terms = get_term($selected_folder);
1232 if(!empty($terms) && isset($terms->slug)) {
1233 wp_set_object_terms($post->ID, $terms->slug, $post_type );
1234 }
1235
1236 }
1237 }
1238 }
1239
1240 public function wcp_folder_send_message_to_owner() {
1241 if (current_user_can('manage_options')) {
1242 $response = array();
1243 $response['status'] = 0;
1244 $response['error'] = 0;
1245 $response['errors'] = array();
1246 $response['message'] = "";
1247 $errorArray = [];
1248 $errorMessage = esc_attr__("%s is required", WCP_FOLDER);
1249 $postData = filter_input_array(INPUT_POST);
1250 if (!isset($postData['textarea_text']) || trim($postData['textarea_text']) == "") {
1251 $error = array(
1252 "key" => "textarea_text",
1253 "message" => esc_attr__("Please enter your message", WCP_FOLDER)
1254 );
1255 $errorArray[] = $error;
1256 }
1257 if (!isset($postData['user_email']) || trim($postData['user_email']) == "") {
1258 $error = array(
1259 "key" => "user_email",
1260 "message" => sprintf($errorMessage, __("Email", WCP_FOLDER))
1261 );
1262 $errorArray[] = $error;
1263 } else if (!filter_var($postData['user_email'], FILTER_VALIDATE_EMAIL)) {
1264 $error = array(
1265 'key' => "user_email",
1266 "message" => "Email is not valid"
1267 );
1268 $errorArray[] = $error;
1269 }
1270 if (empty($errorArray)) {
1271 if (!isset($postData['folder_help_nonce']) || trim($postData['folder_help_nonce']) == "") {
1272 $error = array(
1273 "key" => "nonce",
1274 "message" => esc_attr__("Your request is not valid", WCP_FOLDER)
1275 );
1276 $errorArray[] = $error;
1277 } else {
1278 if (!wp_verify_nonce($postData['folder_help_nonce'], 'wcp_folder_help_nonce')) {
1279 $error = array(
1280 "key" => "nonce",
1281 "message" => esc_attr__("Your request is not valid", WCP_FOLDER)
1282 );
1283 $errorArray[] = $error;
1284 }
1285 }
1286 }
1287 if (empty($errorArray)) {
1288 global $current_user;
1289 $text_message = self::sanitize_options($postData['textarea_text']);
1290 $email = self::sanitize_options($postData['user_email'], "email");
1291 $domain = site_url();
1292 $user_name = $current_user->first_name . " " . $current_user->last_name;
1293 $subject = "Folder request: " . $domain;
1294 $headers = "MIME-Version: 1.0\r\n";
1295 $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
1296 $headers .= 'From: ' . $user_name . ' <' . $email . '>' . PHP_EOL;
1297 $headers .= 'Reply-To: ' . $user_name . ' <' . $email . '>' . PHP_EOL;
1298 $headers .= 'X-Mailer: PHP/' . phpversion();
1299 ob_start();
1300 ?>
1301 <table border="0" cellspacing="0" cellpadding="5">
1302 <tr>
1303 <th>Domain</th>
1304 <td><?php echo esc_attr($domain) ?></td>
1305 </tr>
1306 <tr>
1307 <th>Email</th>
1308 <td><?php echo esc_attr($email) ?></td>
1309 </tr>
1310 <tr>
1311 <th>Message</th>
1312 <td><?php echo nl2br($text_message) ?></td>
1313 </tr>
1314 </table>
1315 <?php
1316 $message = ob_get_clean();
1317 $email_id = "gal@premio.io, karina@premio.io";
1318 $status = wp_mail($email_id, $subject, $message, $headers);
1319 if ($status) {
1320 $response['status'] = 1;
1321 } else {
1322 $response['status'] = 0;
1323 $response['message'] = "Not able to send mail";
1324 }
1325 } else {
1326 $response['error'] = 1;
1327 $response['errors'] = $errorArray;
1328 }
1329 echo json_encode($response);
1330 }
1331 }
1332
1333 public function folder_plugin_deactivate() {
1334 if (current_user_can('manage_options')) {
1335 global $current_user;
1336 $postData = filter_input_array(INPUT_POST);
1337 $errorCounter = 0;
1338 $response = array();
1339 $response['status'] = 0;
1340 $response['message'] = "";
1341 $response['valid'] = 1;
1342 if(!isset($postData['reason']) || empty($postData['reason'])) {
1343 $errorCounter++;
1344 $response['message'] = "Please provide reason";
1345 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1346 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1347 $errorCounter++;
1348 $response['valid'] = 0;
1349 } else {
1350 $nonce = self::sanitize_options($postData['nonce']);
1351 if(!wp_verify_nonce($nonce, 'wcp_folder_deactivate_nonce')) {
1352 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1353 $errorCounter++;
1354 $response['valid'] = 0;
1355 }
1356 }
1357 if($errorCounter == 0) {
1358 $reason = $postData['reason'];
1359 $email = "none@none.none";
1360 if (isset($postData['email_id']) && !empty($postData['email_id']) && filter_var($postData['email_id'], FILTER_VALIDATE_EMAIL)) {
1361 $email = $postData['email_id'];
1362 }
1363 $domain = site_url();
1364 $user_name = $current_user->first_name." ".$current_user->last_name;
1365 $subject = "Folders was removed from {$domain}";
1366 $headers = "MIME-Version: 1.0\r\n";
1367 $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
1368 $headers .= 'From: '.$user_name.' <'.$email.'>'.PHP_EOL ;
1369 $headers .= 'Reply-To: '.$user_name.' <'.$email.'>'.PHP_EOL ;
1370 $headers .= 'X-Mailer: PHP/' . phpversion();
1371 ob_start();
1372 ?>
1373 <table border="0" cellspacing="0" cellpadding="5">
1374 <tr>
1375 <th>Plugin</th>
1376 <td>Folders</td>
1377 </tr>
1378 <tr>
1379 <th>Plugin Version</th>
1380 <!-- Free Pro Version Change -->
1381 <td><?php echo esc_attr(WCP_FOLDER_VERSION) ?></td>
1382 </tr>
1383 <tr>
1384 <th>Domain</th>
1385 <td><?php echo esc_attr($domain) ?></td>
1386 </tr>
1387 <tr>
1388 <th>Email</th>
1389 <td><?php echo esc_attr($email) ?></td>
1390 </tr>
1391 <tr>
1392 <th>Comment</th>
1393 <td><?php echo nl2br($reason) ?></td>
1394 </tr>
1395 <tr>
1396 <th>WordPress Version</th>
1397 <td><?php echo esc_attr(get_bloginfo('version')) ?></td>
1398 </tr>
1399 <tr>
1400 <th>PHP Version</th>
1401 <td><?php echo esc_attr(PHP_VERSION) ?></td>
1402 </tr>
1403 </table>
1404 <?php
1405 $content = ob_get_clean();
1406 $email_id = "gal@premio.io, karina@premio.io";
1407 wp_mail($email_id, $subject, $content, $headers);
1408 $response['status'] = 1;
1409 }
1410 echo json_encode($response);
1411 wp_die();
1412 }
1413 }
1414
1415 public static function ttl_fldrs() {
1416 $post_types = get_option(WCP_FOLDER_VAR);
1417 $post_types = is_array($post_types) ? $post_types : array();
1418 $total = 0;
1419 foreach ($post_types as $post_type) {
1420 $post_type = self::get_custom_post_type($post_type);
1421 $total += wp_count_terms($post_type);
1422 }
1423 return $total;
1424 }
1425
1426 public function wcp_remove_post_item()
1427 {
1428 $response = array();
1429 $response['status'] = 0;
1430 $response['error'] = 0;
1431 $response['data'] = array();
1432 $response['message'] = "";
1433 $postData = filter_input_array(INPUT_POST);
1434 if (isset($postData['post_id']) && !empty($postData['post_id'])) {
1435 wp_delete_post($postData['post_id']);
1436 $response['status'] = 1;
1437 }
1438 echo json_encode($response);
1439 wp_die();
1440 }
1441
1442 public function wcp_change_all_status()
1443 {
1444 $response = array();
1445 $response['status'] = 0;
1446 $response['error'] = 0;
1447 $response['data'] = array();
1448 $response['message'] = "";
1449 $postData = filter_input_array(INPUT_POST);
1450 $errorCounter = 0;
1451 if (!isset($postData['type']) || empty($postData['type'])) {
1452 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1453 $errorCounter++;
1454 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1455 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1456 $errorCounter++;
1457 } else if (!current_user_can("manage_categories") || ($postData['type'] == "page" && !current_user_can("edit_pages"))) {
1458 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
1459 $errorCounter++;
1460 } else if (!current_user_can("manage_categories") || ($postData['type'] != "page" && !current_user_can("edit_posts"))) {
1461 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
1462 $errorCounter++;
1463 } else {
1464 $type = self::sanitize_options($postData['type']);
1465 $nonce = self::sanitize_options($postData['nonce']);
1466 if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
1467 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1468 $errorCounter++;
1469 }
1470 }
1471 if ($errorCounter == 0) {
1472 if (isset($postData['folders']) || !empty($postData['folders'])) {
1473 $status = isset($postData['status']) ? $postData['status'] : 0;
1474 $status = self::sanitize_options($status);
1475 $folders = self::sanitize_options($postData['folders']);
1476 $folders = trim($folders, ",");
1477 $folders = explode(",", $folders);
1478 foreach ($folders as $folder) {
1479 update_term_meta($folder, "is_active", $status);
1480 }
1481 }
1482 $response['status'] = 1;
1483 }
1484 echo json_encode($response);
1485 wp_die();
1486 }
1487
1488 public function wcp_change_post_width()
1489 {
1490 $response = array();
1491 $response['status'] = 0;
1492 $response['error'] = 0;
1493 $response['data'] = array();
1494 $response['message'] = "";
1495 $postData = filter_input_array(INPUT_POST);
1496 $errorCounter = 0;
1497 if (!isset($postData['width']) || empty($postData['width'])) {
1498 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1499 $errorCounter++;
1500 } else if (!isset($postData['type']) || empty($postData['type'])) {
1501 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1502 $errorCounter++;
1503 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1504 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1505 $errorCounter++;
1506 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
1507 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
1508 $errorCounter++;
1509 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
1510 $response['message'] = esc_attr__("You have not permission to update width", WCP_FOLDER);
1511 $errorCounter++;
1512 } else {
1513 $type = self::sanitize_options($postData['type']);
1514 $nonce = self::sanitize_options($postData['nonce']);
1515 if(!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) {
1516 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1517 $errorCounter++;
1518 }
1519 }
1520 if ($errorCounter == 0) {
1521 $type = self::sanitize_options($postData['type']);
1522 $width = self::sanitize_options($postData['width'], "int");
1523 $optionName = "wcp_dynamic_width_for_" . $type;
1524 update_option($optionName, $width);
1525 $response['status'] = 1;
1526 }
1527 echo json_encode($response);
1528 wp_die();
1529 }
1530
1531 public function wcp_change_multiple_post_folder()
1532 {
1533 $response = array();
1534 $response['status'] = 0;
1535 $response['error'] = 0;
1536 $response['data'] = array();
1537 $response['message'] = "";
1538 $postData = filter_input_array(INPUT_POST);
1539 $errorCounter = 0;
1540 if (!isset($postData['post_ids']) || empty($postData['post_ids'])) {
1541 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1542 $errorCounter++;
1543 } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
1544 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1545 $errorCounter++;
1546 } else if (!isset($postData['type']) || empty($postData['type'])) {
1547 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1548 $errorCounter++;
1549 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1550 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1551 $errorCounter++;
1552 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
1553 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1554 $errorCounter++;
1555 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
1556 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1557 $errorCounter++;
1558 } else {
1559 $folder_id = self::sanitize_options($postData['folder_id']);
1560 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$folder_id)) {
1561 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1562 $errorCounter++;
1563 }
1564 }
1565 if ($errorCounter == 0) {
1566 $postID = self::sanitize_options($postData['post_ids']);
1567 $postID = trim($postID, ",");
1568 $folderID = self::sanitize_options($postData['folder_id']);
1569 $type = self::sanitize_options($postData['type']);
1570 $postArray = explode(",", $postID);
1571 $status = 0;
1572 if(isset($postData['status'])) {
1573 $status = self::sanitize_options($postData['status']);
1574 }
1575 $status = true;
1576
1577 $taxonomy = "";
1578 if(isset($postData['taxonomy'])) {
1579 $taxonomy = self::sanitize_options($postData['taxonomy']);
1580 }
1581 if (is_array($postArray)) {
1582 $post_type = self::get_custom_post_type($type);
1583 foreach ($postArray as $post) {
1584 $terms = get_the_terms($post, $post_type);
1585 if (!empty($terms)) {
1586 foreach ($terms as $term) {
1587 if(!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
1588 wp_remove_object_terms($post, $term->term_id, $post_type);
1589 }
1590 }
1591 }
1592 wp_set_post_terms($post, $folderID, $post_type, $status);
1593 }
1594 }
1595 $response['status'] = 1;
1596 }
1597 echo json_encode($response);
1598 wp_die();
1599 }
1600
1601 public function wcp_change_post_folder()
1602 {
1603 $response = array();
1604 $response['status'] = 0;
1605 $response['error'] = 0;
1606 $response['data'] = array();
1607 $response['message'] = "";
1608 $postData = filter_input_array(INPUT_POST);
1609 $errorCounter = 0;
1610 if (!isset($postData['post_id']) || empty($postData['post_id'])) {
1611 $errorCounter++;
1612 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1613 } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) {
1614 $errorCounter++;
1615 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1616 } else if (!isset($postData['type']) || empty($postData['type'])) {
1617 $errorCounter++;
1618 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1619 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1620 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1621 $errorCounter++;
1622 } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) {
1623 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1624 $errorCounter++;
1625 } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) {
1626 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1627 $errorCounter++;
1628 } else {
1629 $term_id = self::sanitize_options($postData['folder_id']);
1630 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
1631 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1632 $errorCounter++;
1633 }
1634 }
1635 if ($errorCounter == 0) {
1636 $postID = self::sanitize_options($postData['post_id']);
1637 $folderID = self::sanitize_options($postData['folder_id']);
1638 $type = self::sanitize_options($postData['type']);
1639 $folder_post_type = self::get_custom_post_type($type);
1640 $status = 0;
1641 if(isset($postData['status'])) {
1642 $status = self::sanitize_options($postData['status']);
1643 }
1644 $status = ($status == 1)?true:false;
1645 $taxonomy = "";
1646 if(isset($postData['taxonomy'])) {
1647 $taxonomy = self::sanitize_options($postData['taxonomy']);
1648 }
1649 $terms = get_the_terms($postID, $folder_post_type);
1650 if (!empty($terms)) {
1651 foreach ($terms as $term) {
1652 if(!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) {
1653 wp_remove_object_terms($postID, $term->term_id, $folder_post_type);
1654 }
1655 }
1656 }
1657 wp_set_post_terms($postID, $folderID, $folder_post_type, true);
1658 $response['status'] = 1;
1659 }
1660 echo json_encode($response);
1661 wp_die();
1662 }
1663
1664 public function wcp_mark_un_mark_folder()
1665 {
1666 $response = array();
1667 $response['status'] = 0;
1668 $response['error'] = 0;
1669 $response['data'] = array();
1670 $response['message'] = "";
1671 $postData = filter_input_array(INPUT_POST);
1672 $errorCounter = 0;
1673 if (!current_user_can("manage_categories")) {
1674 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1675 $errorCounter++;
1676 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1677 $errorCounter++;
1678 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1679 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1680 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1681 $errorCounter++;
1682 } else {
1683 $term_id = self::sanitize_options($postData['term_id']);
1684 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
1685 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1686 $errorCounter++;
1687 }
1688 }
1689 if ($errorCounter == 0) {
1690 $term_id = self::sanitize_options($postData['term_id']);
1691 $status = get_term_meta($term_id, "is_highlighted", true);
1692 if ($status == 1) {
1693 update_term_meta($term_id, "is_highlighted", 0);
1694 $status = 0;
1695 } else {
1696 update_term_meta($term_id, "is_highlighted", 1);
1697 $status = 1;
1698 }
1699 $response['marked'] = $status;
1700 $response['id'] = $postData['term_id'];
1701 $response['status'] = 1;
1702 }
1703 echo json_encode($response);
1704 wp_die();
1705 }
1706
1707 public function wcp_make_sticky_folder()
1708 {
1709 $response = array();
1710 $response['status'] = 0;
1711 $response['error'] = 0;
1712 $response['data'] = array();
1713 $response['message'] = "";
1714 $postData = filter_input_array(INPUT_POST);
1715 $errorCounter = 0;
1716 if (!current_user_can("manage_categories")) {
1717 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1718 $errorCounter++;
1719 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1720 $errorCounter++;
1721 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1722 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1723 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1724 $errorCounter++;
1725 } else {
1726 $term_id = self::sanitize_options($postData['term_id']);
1727 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
1728 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1729 $errorCounter++;
1730 }
1731 }
1732 if ($errorCounter == 0) {
1733 $term_id = self::sanitize_options($postData['term_id']);
1734 $status = get_term_meta($term_id, "is_folder_sticky", true);
1735 if ($status == 1) {
1736 update_term_meta($term_id, "is_folder_sticky", 0);
1737 $status = 0;
1738 } else {
1739 update_term_meta($term_id, "is_folder_sticky", 1);
1740 $status = 1;
1741 }
1742 $response['is_folder_sticky'] = $status;
1743 $response['id'] = $postData['term_id'];
1744 $response['status'] = 1;
1745 }
1746 echo json_encode($response);
1747 wp_die();
1748 }
1749
1750 public function wcp_save_folder_order()
1751 {
1752 $response = array();
1753 $response['status'] = 0;
1754 $response['error'] = 0;
1755 $response['data'] = array();
1756 $response['message'] = "";
1757 $postData = filter_input_array(INPUT_POST);
1758 $errorCounter = 0;
1759 if (!current_user_can("manage_categories")) {
1760 $response['message'] = esc_attr__("You have not permission to update folder order", WCP_FOLDER);
1761 $errorCounter++;
1762 } else if (!isset($postData['term_ids']) || empty($postData['term_ids'])) {
1763 $errorCounter++;
1764 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1765 } else if (!isset($postData['type']) || empty($postData['type'])) {
1766 $errorCounter++;
1767 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1768 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1769 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1770 $errorCounter++;
1771 } else {
1772 $type = self::sanitize_options($postData['type']);
1773 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
1774 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1775 $errorCounter++;
1776 }
1777 }
1778 if ($errorCounter == 0) {
1779 $termIds = self::sanitize_options(($postData['term_ids']));
1780 $type = self::sanitize_options($postData['type']);
1781 $termIds = trim($termIds, ",");
1782 $termArray = explode(",", $termIds);
1783 $order = 1;
1784 foreach ($termArray as $term) {
1785 if (!empty($term)) {
1786 update_term_meta($term, "wcp_custom_order", $order);
1787 $order++;
1788 }
1789 }
1790 $term_id = self::sanitize_options($postData['term_id']);
1791 $parent_id = self::sanitize_options($postData['parent_id']);
1792 $type = self::sanitize_options($postData['type']);
1793 $folder_type = self::get_custom_post_type($type);
1794 wp_update_term($term_id, $folder_type, array(
1795 'parent' => $parent_id
1796 ));
1797
1798 $response['status'] = 1;
1799 $folder_type = self::get_custom_post_type($type);
1800 /* Free/Pro Class name change */
1801 $response['options'] = WCP_Tree::get_option_data_for_select($folder_type);
1802 }
1803 echo json_encode($response);
1804 wp_die();
1805 }
1806
1807 public function save_wcp_folder_state()
1808 {
1809 $response = array();
1810 $response['status'] = 0;
1811 $response['error'] = 0;
1812 $response['data'] = array();
1813 $response['message'] = "";
1814 $postData = filter_input_array(INPUT_POST);
1815 $errorCounter = 0;
1816 if (!current_user_can("manage_categories")) {
1817 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1818 $errorCounter++;
1819 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1820 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1821 $errorCounter++;
1822 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1823 $response['message'] = esc_attr__("Unable to create folder, Your request is not valid", WCP_FOLDER);
1824 $errorCounter++;
1825 } else {
1826 $term_id = self::sanitize_options($postData['term_id']);
1827 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
1828 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1829 $errorCounter++;
1830 }
1831 }
1832 if ($errorCounter == 0) {
1833 $response['status'] = 1;
1834 $term_id = self::sanitize_options($postData['term_id']);
1835 $is_active = isset($postData['is_active'])?$postData['is_active']:0;
1836 $is_active = self::sanitize_options($is_active);
1837 if ($is_active == 1) {
1838 update_term_meta($term_id, "is_active", 1);
1839 } else {
1840 update_term_meta($term_id, "is_active", 0);
1841 }
1842 }
1843 echo json_encode($response);
1844 wp_die();
1845 }
1846
1847 public function wcp_update_parent_information()
1848 {
1849 $response = array();
1850 $response['status'] = 0;
1851 $response['error'] = 0;
1852 $response['data'] = array();
1853 $response['message'] = "";
1854 $postData = filter_input_array(INPUT_POST);
1855 $errorCounter = 0;
1856 if (!current_user_can("manage_categories")) {
1857 $response['message'] = esc_attr__("You have not permission to update folder", WCP_FOLDER);
1858 $errorCounter++;
1859 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1860 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1861 $errorCounter++;
1862 } else if (!isset($postData['type']) || empty($postData['type'])) {
1863 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1864 $errorCounter++;
1865 } else if (!isset($postData['parent_id'])) {
1866 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1867 $errorCounter++;
1868 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1869 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1870 $errorCounter++;
1871 } else {
1872 $term_id = self::sanitize_options($postData['term_id']);
1873 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
1874 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1875 $errorCounter++;
1876 }
1877 }
1878 if($errorCounter == 0) {
1879 $term_id = self::sanitize_options($postData['term_id']);
1880 $parent_id = self::sanitize_options($postData['parent_id']);
1881 $type = self::sanitize_options($postData['type']);
1882 $folder_type = self::get_custom_post_type($type);
1883 wp_update_term($term_id, $folder_type, array(
1884 'parent' => $parent_id
1885 ));
1886 update_term_meta($parent_id, "is_active", 1);
1887 $response['status'] = 1;
1888 }
1889 echo json_encode($response);
1890 wp_die();
1891 }
1892
1893 public function wcp_save_parent_data()
1894 {
1895 $response = array();
1896 $response['status'] = 0;
1897 $response['error'] = 0;
1898 $response['data'] = array();
1899 $response['message'] = "";
1900 $postData = filter_input_array(INPUT_POST);
1901 $errorCounter = 0;
1902 if (!isset($postData['type']) || empty($postData['type'])) {
1903 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1904 $errorCounter++;
1905 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1906 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1907 $errorCounter++;
1908 } else if (!current_user_can("manage_categories")) {
1909 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1910 $errorCounter++;
1911 } else {
1912 $type = self::sanitize_options($postData['type']);
1913 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
1914 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1915 $errorCounter++;
1916 }
1917 }
1918 if ($errorCounter == 0) {
1919 $type = self::sanitize_options($postData['type']);
1920 $optionName = $type . "_parent_status";
1921 $response['status'] = 1;
1922 $is_active = isset($postData['is_active'])?$postData['is_active']:0;
1923 $is_active = self::sanitize_options($is_active);
1924 if ($is_active == 1) {
1925 update_option($optionName, 1);
1926 } else {
1927 update_option($optionName, 0);
1928 }
1929 }
1930 echo json_encode($response);
1931 wp_die();
1932 }
1933
1934 public function remove_muliple_folder(){
1935 $response = array();
1936 $response['status'] = 0;
1937 $response['error'] = 0;
1938 $response['data'] = array();
1939 $response['message'] = "";
1940 $postData = filter_input_array(INPUT_POST);
1941 $errorCounter = 0;
1942 $error = "";
1943 if (!current_user_can("manage_categories")) {
1944 $error = esc_attr__("You have not permission to remove folder", WCP_FOLDER);
1945 $errorCounter++;
1946 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
1947 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
1948 $errorCounter++;
1949 } else if (!isset($postData['type']) || empty($postData['type'])) {
1950 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
1951 $errorCounter++;
1952 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
1953 $response['message'] = esc_attr__("Your request is not valid", WCP_FOLDER);
1954 $errorCounter++;
1955 } else {
1956 $type = self::sanitize_options($postData['type']);
1957 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
1958 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
1959 $errorCounter++;
1960 }
1961 }
1962 if ($errorCounter == 0) {
1963 $term_id = self::sanitize_options($postData['term_id']);
1964 $type = self::sanitize_options($postData['type']);
1965 $response['term_ids'] = array();
1966 if(!empty($term_id)) {
1967 $term_id = trim($term_id,",");
1968 $term_ids = explode(",", $term_id);
1969 if(is_array($term_ids) && count($term_ids) > 0) {
1970 foreach ($term_ids as $term) {
1971 self::remove_folder_child_items($term, $type);
1972 }
1973 $response['term_ids'] = $term_ids;
1974 }
1975 }
1976 $is_active = 1;
1977 $folders = -1;
1978 $response['status'] = 1;
1979 if (!self::check_has_valid_key()) {
1980 $is_active = 0;
1981 $folders = self::ttl_fldrs();
1982 }
1983 $response['folders'] = $folders;
1984 $response['is_key_active'] = $is_active;
1985 } else {
1986 $response['error'] = 1;
1987 $response['message'] = $error;
1988 }
1989 echo json_encode($response);
1990 wp_die();
1991 }
1992
1993 public function wcp_remove_folder()
1994 {
1995 $response = array();
1996 $response['status'] = 0;
1997 $response['error'] = 0;
1998 $response['data'] = array();
1999 $response['message'] = "";
2000 $postData = filter_input_array(INPUT_POST);
2001 $errorCounter = 0;
2002 if (!current_user_can("manage_categories")) {
2003 $error = esc_attr__("You have not permission to remove folder", WCP_FOLDER);
2004 $errorCounter++;
2005 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
2006 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
2007 $errorCounter++;
2008 } else if (!isset($postData['type']) || empty($postData['type'])) {
2009 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
2010 $errorCounter++;
2011 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2012 $error = esc_attr__("Unable to delete folder, Your request is not valid", WCP_FOLDER);
2013 $errorCounter++;
2014 } else {
2015 $term_id = self::sanitize_options($postData['term_id']);
2016 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2017 $error = esc_attr__("Unable to delete folder, Your request is not valid", WCP_FOLDER);
2018 $errorCounter++;
2019 }
2020 }
2021 if ($errorCounter == 0) {
2022 $term_id = self::sanitize_options($postData['term_id']);
2023 $type = self::sanitize_options($postData['type']);
2024 self::remove_folder_child_items($term_id, $type);
2025 $response['status'] = 1;
2026 $is_active = 1;
2027 $folders = -1;
2028 if (!self::check_has_valid_key()) {
2029 $is_active = 0;
2030 $folders = self::ttl_fldrs();
2031 }
2032 $response['folders'] = $folders;
2033 $response['term_id'] = $term_id;
2034 $response['is_key_active'] = $is_active;
2035 } else {
2036 $response['error'] = 1;
2037 $response['message'] = $error;
2038 }
2039 echo json_encode($response);
2040 wp_die();
2041 }
2042
2043 public function remove_folder_child_items($term_id, $post_type)
2044 {
2045 $folder_type = self::get_custom_post_type($post_type);
2046 $terms = get_terms($folder_type, array(
2047 'hide_empty' => false,
2048 'parent' => $term_id
2049 ));
2050
2051 if (!empty($terms)) {
2052 foreach ($terms as $term) {
2053 self::remove_folder_child_items($term->term_id, $post_type);
2054 }
2055 wp_delete_term($term_id, $folder_type);
2056 } else {
2057 wp_delete_term($term_id, $folder_type);
2058 }
2059 }
2060
2061 public function wcp_update_folder()
2062 {
2063 $response = array();
2064 $response['status'] = 0;
2065 $response['error'] = 0;
2066 $response['data'] = array();
2067 $response['message'] = "";
2068 $postData = $_REQUEST;
2069 $errorCounter = 0;
2070 if (!current_user_can("manage_categories")) {
2071 $error = esc_attr__("You have not permission to update folder", WCP_FOLDER);
2072 $errorCounter++;
2073 } else if (!isset($postData['term_id']) || empty($postData['term_id'])) {
2074 $error = esc_attr__("Unable to rename folder, Your request is not valid", WCP_FOLDER);
2075 $errorCounter++;
2076 } else if (!isset($postData['name']) || empty($postData['name'])) {
2077 $error = esc_attr__("Folder name can no be empty", WCP_FOLDER);
2078 $errorCounter++;
2079 } else if (!isset($postData['type']) || empty($postData['type'])) {
2080 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
2081 $errorCounter++;
2082 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2083 $error = esc_attr__("Unable to rename folder, Your request is not valid", WCP_FOLDER);
2084 $errorCounter++;
2085 } else {
2086 $term_id = self::sanitize_options($postData['term_id']);
2087 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) {
2088 $error = esc_attr__("Unable to rename folder, Your request is not valid", WCP_FOLDER);
2089 $errorCounter++;
2090 }
2091 }
2092 if ($errorCounter == 0) {
2093 $type = self::sanitize_options($postData['type']);
2094 $folder_type = self::get_custom_post_type($type);
2095 $name = self::sanitize_options($postData['name']);
2096 $term_id = self::sanitize_options($postData['term_id']);
2097 $result = wp_update_term(
2098 $term_id,
2099 $folder_type,
2100 array(
2101 'name' => $name,
2102 )
2103 );
2104 if (!empty($result)) {
2105 $term_nonce = wp_create_nonce('wcp_folder_term_'.$result['term_id']);
2106 $response['id'] = $result['term_id'];
2107 $response['slug'] = $result['slug'];
2108 $response['status'] = 1;
2109 $response['term_title'] = $postData['name'];
2110 $response['nonce'] = $term_nonce;
2111 } else {
2112 $response['message'] = esc_attr__("Unable to rename folder", WCP_FOLDER);
2113 }
2114 } else {
2115 $response['error'] = 1;
2116 $response['message'] = $error;
2117 }
2118 echo json_encode($response);
2119 wp_die();
2120 }
2121
2122 public function create_slug_from_string($str)
2123 {
2124 $a = array('À', 'Á', 'Â', 'Ã', 'Ä', '�
2125 ', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', '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', '?', '?', '?', '?', '?', '?');
2126 $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');
2127 return strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'), array('', '-', ''), str_replace($a, $b, $str)));
2128 }
2129
2130 public static function sanitize_options($value, $type = "") {
2131 $value = stripslashes($value);
2132 if($type == "int") {
2133 $value = filter_var($value, FILTER_SANITIZE_NUMBER_INT);
2134 } else if($type == "email") {
2135 $value = filter_var($value, FILTER_SANITIZE_EMAIL);
2136 } else {
2137 $value = filter_var($value, FILTER_SANITIZE_STRING);
2138 }
2139 return $value;
2140 }
2141
2142 public function wcp_add_new_folder()
2143 {
2144 $response = array();
2145 $response['status'] = 0;
2146 $response['error'] = 0;
2147 $response['login'] = 1;
2148 $response['data'] = array();
2149 $response['message'] = "";
2150 $postData = $_REQUEST;
2151 $errorCounter = 0;
2152 if (!current_user_can("manage_categories")) {
2153 $error = esc_attr__("You have not permission to add folder", WCP_FOLDER);
2154 $errorCounter++;
2155 } else if (!isset($postData['name']) || empty($postData['name'])) {
2156 $error = esc_attr__("Folder name can no be empty", WCP_FOLDER);
2157 $errorCounter++;
2158 } else if (!isset($postData['type']) || empty($postData['type'])) {
2159 $error = esc_attr__("Your request is not valid", WCP_FOLDER);
2160 $errorCounter++;
2161 } else if (!isset($postData['nonce']) || empty($postData['nonce'])) {
2162 $response['login'] = 0;
2163 $error = esc_attr__("Unable to create folder, Your request is not valid", WCP_FOLDER);
2164 $errorCounter++;
2165 } else {
2166 $type = self::sanitize_options($postData['type']);
2167 if(!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) {
2168 $response['login'] = 0;
2169 $error = esc_attr__("Unable to create folder, Your request is not valid", WCP_FOLDER);
2170 $errorCounter++;
2171 }
2172 }
2173 if ($errorCounter == 0) {
2174 $parent = isset($postData['parent_id']) && !empty($postData['parent_id']) ? $postData['parent_id'] : 0;
2175 $parent = self::sanitize_options($parent);
2176 $type = self::sanitize_options($postData['type']);
2177 $folder_type = self::get_custom_post_type($type);
2178 $term_name = self::sanitize_options($postData['name']);
2179 $term = term_exists($term_name, $folder_type, $parent);
2180 if (!(0 !== $term && null !== $term)) {
2181 $slug = self::create_slug_from_string($postData['name']) . "-" . time();
2182 $result = wp_insert_term(
2183 urldecode($postData['name']), // the term
2184 $folder_type, // the taxonomy
2185 array(
2186 'parent' => $parent,
2187 'slug' => $slug
2188 )
2189 );
2190 if (!empty($result)) {
2191 $response['id'] = $result['term_id'];
2192 $response['status'] = 1;
2193 $term = get_term($result['term_id'], $folder_type);
2194 $order = isset($postData['order']) ? $postData['order'] : 0;
2195 $order = self::sanitize_options($order);
2196 update_term_meta($result['term_id'], "wcp_custom_order", $order);
2197 if ($parent != 0) {
2198 update_term_meta($parent, "is_active", 1);
2199 }
2200
2201 $class = "";
2202
2203 if(isset($postData['is_duplicate']) && $postData['is_duplicate'] == true) {
2204 if(isset($postData['duplicate_from']) && !empty($postData['duplicate_from'])) {
2205 $term_id = $postData['duplicate_from'];
2206
2207 $term_data = get_term($term_id, $folder_type);
2208 if(!empty($term_data)) {
2209 $is_sticky = get_term_meta($term_id, "is_folder_sticky", true);
2210
2211 if($is_sticky == 1) {
2212 $class .= " is-sticky";
2213 add_term_meta($term->term_id, "is_folder_sticky", 1);
2214 }
2215
2216 $status = get_term_meta($term_id, "is_highlighted", true);
2217 if($status == 1) {
2218 add_term_meta($term->term_id, "is_highlighted", 1);
2219 $class .= " is-high";
2220 }
2221
2222 $count = ($term_data->count != 0)?"<span class='total-count'>{$term_data->count}</span>":"";
2223
2224 // if(!empty($term_data->count)) {
2225 $postArray = get_posts(
2226 array(
2227 'posts_per_page' => -1,
2228 'post_type' => $type,
2229 'tax_query' => array(
2230 array(
2231 'taxonomy' => $folder_type,
2232 'field' => 'term_id',
2233 'terms' => $term_id,
2234 )
2235 )
2236 )
2237 );
2238 if(!empty($postArray)) {
2239 foreach($postArray as $p) {
2240 wp_set_post_terms($p->ID, $term->term_id, $folder_type, true);
2241 }
2242 }
2243 // }
2244 }
2245 }
2246 }
2247 $term_nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id);
2248 /* Free/Pro URL Change */
2249 $response['parent_id'] = $parent;
2250 $response['slug'] = $term->slug;
2251 $response['nonce'] = $term_nonce;
2252 $response['term_id'] = $result['term_id'];
2253 $response['title'] = urldecode($postData['name']);
2254 $response['parent_id'] = empty($postData['parent_id'])?"#":$postData['parent_id'];
2255
2256 $is_active = 1;
2257 $folders = -1;
2258 if (!self::check_has_valid_key()) {
2259 $is_active = 0;
2260 $folders = self::ttl_fldrs();
2261 }
2262 $response['is_key_active'] = $is_active;
2263 $response['folders'] = $folders;
2264 } else {
2265 $response['message'] = esc_attr__("Error during server request", WCP_FOLDER);
2266 }
2267 } else {
2268 $response['error'] = 1;
2269 $response['message'] = esc_attr__("Folder name already exists", WCP_FOLDER);
2270 }
2271 } else {
2272 $response['error'] = 1;
2273 $response['message'] = $error;
2274 }
2275 echo json_encode($response);
2276 wp_die();
2277 }
2278
2279 public function is_for_this_post_type($post_type)
2280 {
2281 $post_types = get_option(WCP_FOLDER_VAR);
2282 $post_types = is_array($post_types)?$post_types:array();
2283 return in_array($post_type, $post_types);
2284 }
2285
2286 public function is_active_for_screen()
2287 {
2288 global $typenow, $current_screen;
2289
2290 $postData = filter_input_array(INPUT_POST);
2291
2292
2293 // if ((isset($postData['action']) && $postData['action'] == 'inline-save') && (isset($postData['post_type']) && self::is_for_this_post_type($postData['post_type']))) {
2294 // return true;
2295 // }
2296 global $current_screen;
2297
2298 if (self::is_for_this_post_type($typenow) && ('edit' == $current_screen->base || 'upload' == $current_screen->base)) {
2299 return true;
2300 }
2301
2302 $post_types = get_option(WCP_FOLDER_VAR);
2303 $post_types = is_array($post_types)?$post_types:array();
2304
2305 if(empty($typenow) && 'upload' == $current_screen->base ) {
2306 $typenow = "attachment";
2307 if (self::is_for_this_post_type($typenow)) {
2308 return true;
2309 }
2310 }
2311 return false;
2312 }
2313
2314 public function is_add_update_screen()
2315 {
2316 global $current_screen;
2317 $current_type = $current_screen->base;
2318 $action = $current_screen->action;
2319 $post_types = get_option(WCP_FOLDER_VAR);
2320 $post_types = is_array($post_types)?$post_types:array();
2321 global $typenow;
2322 if (in_array($current_type, $post_types) && in_array($action, array("add", ""))) {
2323 $license_data = self::get_license_key_data();
2324
2325 $is_active = 1;
2326 $folders = -1;
2327 if (!self::check_has_valid_key()) {
2328 $is_active = 0;
2329 $folders = self::ttl_fldrs();
2330 }
2331 $response['folders'] = $folders;
2332 $response['is_key_active'] = $is_active;
2333 }
2334 }
2335
2336 public static function get_custom_post_type($post_type)
2337 {
2338 if ($post_type == "post") {
2339 return "post_folder";
2340 } else if ($post_type == "page") {
2341 return "folder";
2342 } else if ($post_type == "attachment") {
2343 return "media_folder";
2344 }
2345 return $post_type . '_folder';
2346 }
2347
2348 public function admin_footer()
2349 {
2350 if (self::is_active_for_screen()) {
2351 global $typenow;
2352
2353 self::set_default_values_if_not_exists();
2354
2355 $ttpsts = self::get_ttlpst($typenow);
2356
2357 $ttemp = self::get_tempt_posts($typenow);
2358
2359 $folder_type = self::get_custom_post_type($typenow);
2360 /* Do not change: Free/Pro Class name change */
2361 $tree_data = WCP_Tree::get_full_tree_data($folder_type);
2362 $terms_data = $tree_data['string'];
2363 $sticky_string = $tree_data['sticky_string'];
2364 $terms_html = WCP_Tree::get_option_data_for_select($folder_type);
2365 $form_html = WCP_Forms::get_form_html($terms_html);
2366 include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "admin-content.php";
2367 }
2368
2369 global $pagenow;
2370 if ( 'plugins.php' !== $pagenow ) {
2371
2372 } else {
2373 if (current_user_can('manage_options')) {
2374 include_once dirname(dirname(__FILE__)) . WCP_DS . "/templates" . WCP_DS . "admin" . WCP_DS . "folder-deactivate-form.php";
2375 }
2376 }
2377 }
2378
2379 public function get_ttlpst($post_type = "")
2380 {
2381 global $typenow;
2382 if (empty($post_type)) {
2383 $post_type = $typenow;
2384 }
2385 $item_count = null;
2386 if(has_filter("premio_folder_all_categorized_items")) {
2387 $item_count = apply_filters("premio_folder_all_categorized_items", $post_type);
2388 }
2389 if($item_count === null) {
2390 if ($post_type == "attachment") {
2391 $item_count = wp_count_posts($post_type)->inherit;
2392 } else {
2393 $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;
2394 }
2395 }
2396 return $item_count;
2397 }
2398
2399 public function autoload()
2400 {
2401 $files = array(
2402 'WCP_Tree_View' => WCP_DS . "includes" . WCP_DS . "tree.class.php",
2403 'WCP_Form_View' => WCP_DS . "includes" . WCP_DS . "form.class.php",
2404 'WCP_Folder_WPML' => WCP_DS . "includes" . WCP_DS . "class-wpml.php",
2405 'WCP_Folder_PolyLang' => WCP_DS . "includes" . WCP_DS . "class-polylang.php",
2406 );
2407
2408 foreach ($files as $file) {
2409 if (file_exists(dirname(dirname(__FILE__)) . $file)) {
2410 include_once dirname(dirname(__FILE__)) . $file;
2411 }
2412 }
2413 }
2414
2415 public function create_folder_terms()
2416 {
2417 $options = get_option(WCP_FOLDER_VAR);
2418 $options = is_array($options)?$options:array();
2419 $old_plugin_status = 0;
2420 $posts = array();
2421 if (!empty($options)) {
2422 foreach ($options as $option) {
2423 if (!(strpos($option, 'folder4') === false) && $old_plugin_status == 0) {
2424 $old_plugin_status = 1;
2425 }
2426 if (in_array($option, array("page", "post", "attachment"))) {
2427 $posts[] = str_replace("folder4", "", $option);
2428 } else {
2429 $posts[] = $option;
2430 }
2431 }
2432 if(!empty($posts)) {
2433 update_option(WCP_FOLDER_VAR, $posts);
2434 }
2435 }
2436 if ($old_plugin_status == 1) {
2437 update_option("folders_show_in_menu", "on");
2438 $old_plugin_var = get_option("folder_old_plugin_status");
2439 if (empty($old_plugin_var) || $old_plugin_var == null) {
2440 update_option("folder_old_plugin_status", "1");
2441 }
2442 }
2443 $posts = get_option(WCP_FOLDER_VAR);
2444 if (!empty($posts)) {
2445 foreach ($posts as $post_type) {
2446 $labels = array(
2447 'name' => esc_html__('Folders', WCP_FOLDER),
2448 'singular_name' => esc_html__('Folder', WCP_FOLDER),
2449 'all_items' => esc_html__('All Folders', WCP_FOLDER),
2450 'edit_item' => esc_html__('Edit Folder', WCP_FOLDER),
2451 'update_item' => esc_html__('Update Folder', WCP_FOLDER),
2452 'add_new_item' => esc_html__('Add New Folder', WCP_FOLDER),
2453 'new_item_name' => esc_html__('Add folder name', WCP_FOLDER),
2454 'menu_name' => esc_html__('Folders', WCP_FOLDER),
2455 'search_items' => esc_html__('Search Folders', WCP_FOLDER),
2456 'parent_item' => esc_html__('Parent Folder', WCP_FOLDER),
2457 );
2458
2459 $args = array(
2460 'label' => esc_html__('Folder', WCP_FOLDER),
2461 'labels' => $labels,
2462 'show_tagcloud' => false,
2463 'hierarchical' => true,
2464 'public' => false,
2465 'show_ui' => true,
2466 'show_in_menu' => false,
2467 'show_in_rest' => true,
2468 'show_admin_column' => true,
2469 'update_count_callback' => '_update_generic_term_count',
2470 'query_var' => true,
2471 'rewrite' => false,
2472 'capabilities' => array(
2473 'manage_terms' => 'manage_categories',
2474 'edit_terms' => 'manage_categories',
2475 'delete_terms' => 'manage_categories',
2476 'assign_terms' => 'manage_categories'
2477 )
2478 );
2479
2480 $folder_post_type = self::get_custom_post_type($post_type);
2481
2482 register_taxonomy(
2483 $folder_post_type,
2484 $post_type,
2485 $args
2486 );
2487 }
2488 }
2489
2490 $postData = filter_input_array(INPUT_POST);
2491
2492 if(current_user_can("manage_categories") && isset($postData['folder_nonce'])) {
2493 if(wp_verify_nonce($postData['folder_nonce'], "folder_settings")) {
2494 if (isset($postData['folders_show_in_menu']) && !empty($postData['folders_show_in_menu'])) {
2495 $show_menu = "off";
2496 if ($postData['folders_show_in_menu'] == "on") {
2497 $show_menu = "on";
2498 }
2499 update_option("folders_show_in_menu", $show_menu);
2500 }
2501
2502 if (isset($postData['folders_settings1'])) {
2503 $posts = array();
2504 if (isset($postData['folders_settings']) && is_array($postData['folders_settings'])) {
2505 foreach ($postData['folders_settings'] as $key => $val) {
2506 $posts[] = $val;
2507 }
2508 }
2509 update_option("folders_settings", $posts);
2510 }
2511
2512 if (isset($_POST['folders_settings1'])) {
2513 $posts = array();
2514 if (isset($_POST['default_folders']) && is_array($_POST['default_folders'])) {
2515 foreach ($_POST['default_folders'] as $key => $val) {
2516 $posts[$key] = $val;
2517 }
2518 }
2519 update_option("default_folders", $posts);
2520 }
2521
2522 if (isset($_POST['folders_settings1'])) {
2523 $posts = array();
2524 if (isset($_POST['customize_folders']) && is_array($_POST['customize_folders'])) {
2525 foreach ($_POST['customize_folders'] as $key => $val) {
2526 $posts[$key] = $val;
2527 }
2528 }
2529 update_option("customize_folders", $posts);
2530 }
2531 }
2532 }
2533
2534 $old_version = get_option("folder_old_plugin_status");
2535 if($old_version !== false && $old_version == 1) {
2536 $tlfs = get_option("folder_old_plugin_folder_status");
2537 if($tlfs === false) {
2538 $total = self::ttl_fldrs();
2539 if($total <= 10) {
2540 $total = 10;
2541 };
2542 update_option("folder_old_plugin_folder_status", $total);
2543 self::$folders = $total;
2544 } else {
2545 self::$folders = $tlfs;
2546 }
2547 }
2548
2549 $tlfs = get_option("folder_old_plugin_folder_status");
2550 if($tlfs === false) {
2551 self::$folders = 10;
2552 } else {
2553 self::$folders = $tlfs;
2554 }
2555 }
2556
2557 function searchForId($id, $menu)
2558 {
2559 if ($menu) {
2560 foreach ($menu as $key => $val) {
2561 if (array_key_exists(2, $val)) {
2562 $stripVal = explode('=', $val[2]);
2563 }
2564 if (array_key_exists(1, $stripVal)) {
2565 $stripVal = $stripVal[1];
2566 }
2567 if ($stripVal === $id) {
2568 return $key;
2569 }
2570 }
2571 }
2572 }
2573
2574 function create_menu_for_folders()
2575 {
2576 global $menu;
2577 self::check_and_set_post_type();
2578
2579 $folder_types = get_option("folders_settings");
2580 if (empty($folder_types)) {
2581 return;
2582 }
2583
2584 foreach ($folder_types as $type) {
2585 $itemKey = self::searchForId($type, $menu);
2586 switch (true) {
2587 case ($type == 'attachment'):
2588 $itemKey = 10;
2589 $edit = 'upload.php';
2590 break;
2591 case ($type === 'post'):
2592 $edit = 'edit.php';
2593 $itemKey = 5;
2594 break;
2595 default:
2596 $edit = 'edit.php';
2597 break;
2598 }
2599
2600 $folder = $type == 'attachment' ? 'media' : $type;
2601 $upper = $type == 'attachment' ? 'Media' : ucwords(str_replace(array('-', '_'), ' ', $type));
2602 if ($type == 'page') {
2603 $tax_slug = 'folder';
2604 } else {
2605 $tax_slug = $folder . '_folder';
2606 }
2607
2608
2609 if ($type == 'attachment') {
2610 add_menu_page('Media Folders', 'Media Folders', 'publish_pages', "{$edit}?type=folder", false, 'dashicons-portfolio', "{$itemKey}.5");
2611 } else {
2612 add_menu_page($upper . ' Folders', "{$upper} Folders", 'publish_pages', "{$edit}?post_type={$type}&type=folder", false, 'dashicons-portfolio', "{$itemKey}.5");
2613 }
2614 $terms = get_terms($tax_slug, array(
2615 'hide_empty' => true,
2616 'parent' => 0,
2617 'orderby' => 'meta_value_num',
2618 'order' => 'ASC',
2619 'hierarchical' => false,
2620 'meta_query' => [[
2621 'key' => 'wcp_custom_order',
2622 'type' => 'NUMERIC',
2623 ]]
2624 )
2625 );
2626
2627 if ($terms) {
2628 foreach ($terms as $term) {
2629 if ($type == 'attachment') {
2630 add_submenu_page("{$edit}?type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type=attachment&media_folder={$term->slug}", false);
2631 } else {
2632 add_submenu_page("{$edit}?post_type={$type}&type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type={$type}&{$tax_slug}={$term->slug}", false);
2633 }
2634 }
2635 }
2636 }
2637 }
2638
2639 function folders_admin_styles()
2640 {
2641 if (self::is_active_for_screen()) {
2642 wp_enqueue_style('wcp-folders-fa', plugin_dir_url(dirname(__FILE__)) . 'assets/css/folder-icon.css', array(), WCP_FOLDER_VERSION);
2643 wp_enqueue_style('wcp-folders-admin', plugin_dir_url(dirname(__FILE__)) . 'assets/css/design.min.css', array(), WCP_FOLDER_VERSION);
2644 wp_enqueue_style('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)) . 'assets/css/jstree.min.css', array(), WCP_FOLDER_VERSION);
2645 wp_enqueue_style('wcp-folders-css', plugin_dir_url(dirname(__FILE__)) . 'assets/css/folders.min.css', array(), WCP_FOLDER_VERSION);
2646 }
2647 wp_register_style('wcp-css-handle', false);
2648 wp_enqueue_style('wcp-css-handle');
2649 $css = "
2650 .wcp-folder-upgrade-button {color: #FF5983; font-weight: bold;}
2651 ";
2652 if (self::is_active_for_screen()) {
2653 global $typenow;
2654 $width = get_option("wcp_dynamic_width_for_" . $typenow);
2655 $width = esc_attr($width);
2656 $display_status = "wcp_dynamic_display_status_" . $typenow;
2657 $display_status = get_option($display_status);
2658 if($display_status != "hide") {
2659 if (!empty($width) && is_numeric($width)) {
2660 $css .= ".wcp-content{width:{$width}px}";
2661 if (function_exists('is_rtl') && is_rtl()) {
2662 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:" . ($width + 20) . "px}";
2663 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}";
2664 } else {
2665 $css .= "body.wp-admin #wpcontent {padding-left:" . ($width + 20) . "px}";
2666 }
2667 }
2668 } else {
2669 if (function_exists('is_rtl') && is_rtl()) {
2670 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:20px}";
2671 $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}";
2672 } else {
2673 $css .= "body.wp-admin #wpcontent {padding-left:20px}";
2674 }
2675 }
2676 if (!empty($width) && is_numeric($width)) {
2677 $css .= ".wcp-content {width: {$width}px}";
2678 }
2679 }
2680 wp_add_inline_style('wcp-css-handle', $css);
2681
2682 if (self::is_active_for_screen()) {
2683 global $typenow;
2684 add_filter('views_edit-' . $typenow, array($this, 'wcp_check_for_child_folders'));
2685 }
2686 }
2687
2688 function wcp_check_for_child_folders($content)
2689 {
2690 $termId = 0;
2691 global $typenow;
2692 $post_type = self::get_custom_post_type($typenow);
2693 if (isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
2694 $term = $_GET[$post_type];
2695 $term = get_term_by("slug", $term, $post_type);
2696 if (!empty($term)) {
2697 $termId = $term->term_id;
2698 }
2699 }
2700 $terms = get_terms($post_type, array(
2701 'hide_empty' => false,
2702 'parent' => $termId,
2703 'orderby' => 'meta_value_num',
2704 'order' => 'ASC',
2705 'hierarchical' => false,
2706 'update_count_callback' => '_update_generic_term_count',
2707 'meta_query' => [[
2708 'key' => 'wcp_custom_order',
2709 'type' => 'NUMERIC',
2710 ]]
2711 ));
2712 $optionName = "wcp_folder_display_status_" . $typenow;
2713 $optionValue = get_option($optionName);
2714 $class = (!empty($optionValue) && $optionValue == "hide")?"":"active";
2715 $customize_folders = get_option('customize_folders');
2716 $show_in_page = !isset($customize_folders['show_in_page'])||empty($customize_folders['show_in_page'])?"show":$customize_folders['show_in_page'];
2717 if(empty($show_in_page)) {
2718 $show_in_page = "show";
2719 }
2720 if($show_in_page == "show") {
2721 echo '<div class="tree-structure-content ' . $class . '"><div class="tree-structure" id="list-folder-' . $termId . '" data-id="' . $termId . '">';
2722 echo '<ul>';
2723 foreach ($terms as $term) {
2724 $status = get_term_meta($term->term_id, "is_highlighted", true);
2725 ?>
2726 <li class="grid-view" data-id="<?php echo $term->term_id ?>" id="folder_<?php echo $term->term_id ?>">
2727 <div class="folder-item is-folder" data-id="<?php echo $term->term_id ?>">
2728 <a title='<?php echo $term->name ?>' id="folder_view_<?php echo $term->term_id ?>"
2729 class="folder-view <?php echo ($status == 1) ? "is-high" : "" ?>"
2730 data-id="<?php echo $term->term_id ?>">
2731 <span class="folder item-name"><span id="wcp_folder_text_<?php echo $term->term_id ?>"
2732 class="folder-title"><?php echo $term->name ?></span></span>
2733 <!--<span class="folder-option"></span>-->
2734 </a>
2735 </div>
2736 </li>
2737 <?php
2738 }
2739 echo '</ul>';
2740 echo '<div class="clear clearfix"></div>';
2741 echo '</div>';
2742 echo '<div class="folders-toggle-button"><span></span></div>';
2743 echo '</div>';
2744 }
2745 if(!empty($content) && is_array($content)) {
2746 echo '<ul class="subsubsub">';
2747 foreach($content as $k=>$v) {
2748 echo "<li class='{$k}'>{$v}</li>";
2749 }
2750 echo '</ul>';
2751 }
2752 }
2753
2754 function folders_admin_scripts($hook)
2755 {
2756 if (self::is_active_for_screen()) {
2757 global $typenow;
2758 /* Free/Pro Version change */
2759 wp_enqueue_script('wcp-folders-alert', plugin_dir_url(dirname(__FILE__)) . 'assets/js/livequery.min.js', array(), WCP_FOLDER_VERSION);
2760 // 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);
2761 wp_enqueue_script('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)) . 'assets/js/jstree.min.js', array('jquery'), WCP_FOLDER_VERSION);
2762 wp_enqueue_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)) . 'assets/js/folders.min.js', array('jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'), WCP_FOLDER_VERSION);
2763
2764
2765 $post_type = self::get_custom_post_type($typenow);
2766
2767 if ($typenow == "attachment") {
2768 $admin_url = admin_url("upload.php?post_type=attachment&media_folder=");
2769 } else {
2770 $admin_url = admin_url("edit.php?post_type=" . $typenow);
2771 if (isset($_GET['s']) && !empty($_GET['s'])) {
2772 $admin_url .= "&s=" . $_GET['s'];
2773 }
2774 $admin_url .= "&{$post_type}=";
2775 }
2776
2777 $current_url = $admin_url;
2778 if(isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
2779 $current_url .= $_GET[$post_type];
2780 }
2781
2782
2783 $is_active = 1;
2784 $folders = -1;
2785 if (!self::check_has_valid_key()) {
2786 $is_active = 0;
2787 $folders = self::ttl_fldrs();
2788 }
2789 /* For free: upgrade URL, for Pro: Register Key URL */
2790 $register_url = admin_url("admin.php?page=wcp_folders_upgrade");
2791
2792 $is_rtl = 0;
2793 if ( function_exists( 'is_rtl' ) && is_rtl() ) {
2794 $is_rtl = 1;
2795 }
2796
2797 $can_manage_folder = current_user_can("manage_categories")?1:0;
2798 $width = get_option("wcp_dynamic_width_for_" . $typenow);
2799 $width = empty($width)||!is_numeric($width)?310:$width;
2800 $post_type = self::get_custom_post_type($typenow);
2801 $taxonomy_status = 0;
2802 $selected_taxonomy = "";
2803 if(!isset($_GET[$post_type]) || empty($_GET[$post_type])) {
2804 $taxonomy_status = 1;
2805 } else if(isset($_GET[$post_type]) && !empty($_GET[$post_type])) {
2806 $selected_taxonomy = $_GET[$post_type];
2807
2808 $term = get_term_by('slug', $selected_taxonomy, $post_type);
2809 if (!empty($term) && is_object($term)) {
2810 $selected_taxonomy = $term->term_id;
2811 } else {
2812 $selected_taxonomy = "";
2813 }
2814 }
2815 $customize_folders = get_option('customize_folders');
2816 $show_in_page = !isset($customize_folders['show_in_page'])||empty($customize_folders['show_in_page'])?"show":$customize_folders['show_in_page'];
2817 if(empty($show_in_page)) {
2818 $show_in_page = "show";
2819 }
2820 $taxonomies = self::get_terms_hierarchical($post_type);
2821
2822 $response['terms'] = $taxonomies;
2823 wp_localize_script('wcp-folders-custom', 'wcp_settings', array(
2824 'ajax_url' => admin_url('admin-ajax.php'),
2825 'upgrade_url' => admin_url('admin.php?page=wcp_folders_upgrade'),
2826 'post_type' => $typenow,
2827 'page_url' => $admin_url,
2828 'current_url' => $current_url,
2829 'ajax_image' => plugin_dir_url(dirname(__FILE__)) . "assets/images/ajax-loader.gif",
2830 'is_key_active' => $is_active,
2831 'folders' => $folders,
2832 'register_url' => $register_url,
2833 'isRTL' => $is_rtl,
2834 'nonce' => wp_create_nonce('wcp_folder_nonce_'.$typenow),
2835 'can_manage_folder' => $can_manage_folder,
2836 'folder_width' => $width,
2837 'taxonomy_status' => $taxonomy_status,
2838 'selected_taxonomy' => $selected_taxonomy,
2839 'show_in_page' => $show_in_page,
2840 'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png',
2841 'taxonomies' => $taxonomies,
2842 ));
2843 } else {
2844 self::is_add_update_screen();
2845 }
2846
2847 if($hook == "media-new.php") {
2848 if(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {
2849 wp_enqueue_style( 'folders-media', WCP_FOLDER_URL . 'assets/css/new-media.css' );
2850 $is_active = 1;
2851 $folders = -1;
2852 if (!self::check_has_valid_key()) {
2853 $is_active = 0;
2854 $folders = self::ttl_fldrs();
2855 }
2856
2857 wp_enqueue_script('wcp-folders-add-new-media', plugin_dir_url(dirname(__FILE__)) . 'assets/js/new-media.js', array('jquery'), WCP_FOLDER_VERSION);
2858 wp_localize_script( 'wcp-folders-add-new-media', 'folders_media_options', array(
2859 'terms' => self::get_terms_hierarchical('media_folder'),
2860 'taxonomy' => get_taxonomy('media_folder'),
2861 'ajax_url' => admin_url("admin-ajax.php"),
2862 'activate_url' => admin_url("admin.php?page=wcp_folders_upgrade"),
2863 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'),
2864 'is_key_active' => $is_active,
2865 'folders' => $folders,
2866 ));
2867 }
2868 }
2869 }
2870
2871 public function plugin_action_links($links)
2872 {
2873 array_unshift($links, '<a href="' . admin_url("admin.php?page=wcp_folders_settings") . '" >' . esc_html__('Settings', WCP_FOLDER) . '</a>');
2874 $links['need_help'] = '<a target="_blank" href="https://premio.io/help/folders/?utm_source=pluginspage" >'.__( 'Need help?', WCP_FOLDER).'</a>';
2875
2876 /* PRO link for only for FREE*/
2877 $links['pro'] = '<a class="wcp-folder-upgrade-button" href="'.admin_url("admin.php?page=wcp_folders_upgrade").'" >'.__( 'Upgrade', WCP_FOLDER).'</a>';
2878 return $links;
2879 }
2880
2881 public static function get_instance()
2882 {
2883 if (empty(self::$instance)) {
2884 /* Do not change Class name here */
2885 self::$instance = new WCP_Folders();
2886 }
2887 return self::$instance;
2888 }
2889
2890 public function check_and_set_post_type() {
2891 $options = get_option(WCP_FOLDER_VAR);
2892 $old_plugin_status = 0;
2893 $post_array = array();
2894 if (!empty($options) && is_array($options)) {
2895 foreach ($options as $key=>$val) {
2896 if (!(strpos($key, 'folders4') === false) && $old_plugin_status == 0) {
2897 $old_plugin_status = 1;
2898 }
2899 if (in_array($key, array("folders4page", "folders4post", "folders4attachment"))) {
2900 $post_array[] = str_replace("folders4", "", $key);
2901 }
2902 }
2903 } else {
2904 $post_array = array("page", "post", "attachment");
2905 }
2906 if ($old_plugin_status == 1) {
2907 update_option("folders_show_in_menu", "on");
2908 $old_plugin_var = get_option("folder_old_plugin_status");
2909 if (empty($old_plugin_var) || $old_plugin_var == null) {
2910 update_option("folder_old_plugin_status", "1");
2911 }
2912 update_option(WCP_FOLDER_VAR, $post_array);
2913 self::set_default_values_if_not_exists();
2914 }
2915 if (!empty($post_array) && get_option(WCP_FOLDER_VAR) === false) {
2916 update_option(WCP_FOLDER_VAR, $post_array);
2917 update_option("folders_show_in_menu", "off");
2918 }
2919 }
2920
2921 public static function activate()
2922 {
2923 update_option("folders_show_in_menu", "off");
2924 $option = get_option("folder_redirect_status");
2925 if($option === false) {
2926 add_option("folder_intro_box", "show");
2927 }
2928 update_option("folder_redirect_status", 1);
2929 }
2930
2931 public static function get_ttl_fldrs()
2932 {
2933 return self::ttl_fldrs();
2934 }
2935
2936 function folders_register_settings()
2937 {
2938 register_setting('folders_settings', 'folders_settings1', 'folders_settings_validate');
2939 register_setting('default_folders', 'default_folders');
2940 register_setting('customize_folders', 'customize_folders');
2941
2942 self::check_and_set_post_type();
2943
2944 $option = get_option("folder_redirect_status");
2945 if ($option == 1) {
2946 update_option("folder_redirect_status", 2);
2947 wp_redirect(admin_url("admin.php?page=wcp_folders_settings"));
2948 exit;
2949 }
2950 }
2951
2952 function wcp_manage_columns_head($defaults, $d = "")
2953 {
2954 global $typenow;
2955 $type = $typenow;
2956 if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
2957 $type = self::sanitize_options($_REQUEST['post_type']);
2958 }
2959
2960 $options = get_option("folders_settings");
2961 if (is_array($options) && in_array($type, $options)) {
2962 $columns = array(
2963 '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>',
2964 ) + $defaults;
2965 return $columns;
2966 }
2967 return $defaults;
2968 }
2969
2970 function wcp_manage_columns_content($column_name, $post_ID)
2971 {
2972 $postIDs = self::$postIds;
2973 if(!is_array($postIDs)) {
2974 $postIDs = array();
2975 }
2976 if(!in_array($post_ID, $postIDs)) {
2977 $postIDs[] = $post_ID;
2978 self::$postIds = $postIDs;
2979 global $typenow;
2980 $type = $typenow;
2981 if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
2982 $type = self::sanitize_options($_REQUEST['post_type']);
2983 }
2984
2985 $options = get_option("folders_settings");
2986 if (is_array($options) && in_array($type, $options)) {
2987 if ($column_name == 'wcp_move') {
2988 $title = get_the_title();
2989 if (strlen($title) > 20) {
2990 $title = substr($title, 0, 20) . "...";
2991 }
2992 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>";
2993 }
2994 }
2995 }
2996 }
2997
2998 function taxonomy_archive_exclude_children($query)
2999 {
3000 $options = get_option("folders_settings");
3001 if (!empty($options)) {
3002 $taxonomy_slugs = array();
3003 foreach ($options as $option) {
3004 $taxonomy_slugs[] = self::get_custom_post_type($option);
3005 }
3006 if (!empty($taxonomy_slugs)) {
3007 $i = 0;
3008 foreach ($query->tax_query->queries as $tax_query_item) {
3009 if (empty($taxonomy_slugs) || (isset($tax_query_item['taxonomy']) && in_array($tax_query_item['taxonomy'], $taxonomy_slugs))) {
3010 $query->tax_query->queries[$i]['include_children'] = 0;
3011 }
3012 }
3013 }
3014 }
3015 }
3016
3017 public function admin_menu()
3018 {
3019 // Add menu item for settings page
3020 $page_title = esc_attr__('Folders', WCP_FOLDER);
3021 $menu_title = esc_attr__('Folders Settings', WCP_FOLDER);
3022 $capability = 'manage_options';
3023 $menu_slug = 'wcp_folders_settings';
3024 $callback = array($this, "wcp_folders_settings");
3025 $icon_url = 'dashicons-category';
3026 $position = 99;
3027
3028 add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $position);
3029
3030
3031 $getData = filter_input_array(INPUT_GET);
3032 if(isset($getData['hide_folder_recommended_plugin']) && isset($getData['nonce'])) {
3033 if(current_user_can('manage_options')) {
3034 $nonce = $getData['nonce'];
3035 if(wp_verify_nonce($nonce, "folder_recommended_plugin")) {
3036 update_option('hide_folder_recommended_plugin',"1");
3037 }
3038 }
3039 }
3040
3041 $recommended_plugin = get_option("hide_folder_recommended_plugin");
3042 if($recommended_plugin === false) {
3043 add_submenu_page(
3044 $menu_slug,
3045 esc_html__('Recommended Plugins', WCP_FOLDER),
3046 esc_html__('Recommended Plugins', WCP_FOLDER),
3047 'manage_options',
3048 'recommended-folder-plugins',
3049 array($this, 'recommended_plugins')
3050 );
3051 }
3052
3053 /* Do not Change Free/Pro Change for menu */
3054 add_submenu_page(
3055 $menu_slug,
3056 esc_html__('Upgrade to Pro', WCP_FOLDER),
3057 esc_html__('Upgrade to Pro', WCP_FOLDER),
3058 'manage_options',
3059 'wcp_folders_upgrade',
3060 array($this, 'wcp_folders_upgrade_or_register')
3061 );
3062
3063 self::check_and_set_post_type();
3064
3065 $show_menu = get_option("folders_show_in_menu", true);
3066 if ($show_menu == "on") {
3067 self::create_menu_for_folders();
3068 }
3069 }
3070
3071 public function recommended_plugins() {
3072 include_once dirname(dirname(__FILE__)) . "/templates/admin/recommended-plugins.php";
3073 }
3074
3075 public function wcp_folders_upgrade_or_register()
3076 {
3077 self::set_default_values_if_not_exists();
3078 include_once dirname(dirname(__FILE__)) . "/templates/admin/upgrade-to-pro.php";
3079 }
3080
3081 public function wcp_folders_settings()
3082 {
3083 self::set_default_values_if_not_exists();
3084 /* Only in Free, Get Folders update confirmation popup */
3085 $is_shown = get_option("folder_update_message");
3086 if($is_shown === false) {
3087 include_once dirname(dirname(__FILE__)) . "/templates/admin/update.php";
3088 } else {
3089 $options = get_option('folders_settings');
3090 $options = (empty($options) || !is_array($options)) ? array() : $options;
3091 $post_types = get_post_types(array('public' => true), 'objects');
3092 $terms_data = array();
3093 foreach ($post_types as $post_type) {
3094 if (in_array($post_type->name, $options)) {
3095 $term = $post_type->name;
3096 $term = self::get_custom_post_type($term);
3097 $categories = self::get_terms_hierarchical($term);
3098 $terms_data[$post_type->name] = $categories;
3099 } else {
3100 $terms_data[$post_type->name] = array();
3101 }
3102 }
3103 $fonts = self::get_font_list();
3104 include_once dirname(dirname(__FILE__)) . "/templates/admin/general-settings.php";
3105
3106 $option = get_option("folder_intro_box");
3107 if($option == "show") {
3108 include_once dirname(dirname(__FILE__)) . "/templates/admin/folder-popup.php";
3109 }
3110 }
3111 }
3112
3113 public static function get_font_list(){
3114 return array(
3115 // System fonts.
3116 'Default' => 'Default',
3117 'Arial' => 'Default',
3118 'Tahoma' => 'Default',
3119 'Verdana' => 'Default',
3120 'Helvetica' => 'Default',
3121 'Times New Roman' => 'Default',
3122 'Trebuchet MS' => 'Default',
3123 'Georgia' => 'Default',
3124
3125 // Google Fonts (last update: 23/10/2018).
3126 'ABeeZee' => 'Google Fonts',
3127 'Abel' => 'Google Fonts',
3128 'Abhaya Libre' => 'Google Fonts',
3129 'Abril Fatface' => 'Google Fonts',
3130 'Aclonica' => 'Google Fonts',
3131 'Acme' => 'Google Fonts',
3132 'Actor' => 'Google Fonts',
3133 'Adamina' => 'Google Fonts',
3134 'Advent Pro' => 'Google Fonts',
3135 'Aguafina Script' => 'Google Fonts',
3136 'Akronim' => 'Google Fonts',
3137 'Aladin' => 'Google Fonts',
3138 'Aldrich' => 'Google Fonts',
3139 'Alef' => 'Google Fonts',
3140 'Alef Hebrew' => 'Google Fonts', // Hack for Google Early Access.
3141 'Alegreya' => 'Google Fonts',
3142 'Alegreya SC' => 'Google Fonts',
3143 'Alegreya Sans' => 'Google Fonts',
3144 'Alegreya Sans SC' => 'Google Fonts',
3145 'Alex Brush' => 'Google Fonts',
3146 'Alfa Slab One' => 'Google Fonts',
3147 'Alice' => 'Google Fonts',
3148 'Alike' => 'Google Fonts',
3149 'Alike Angular' => 'Google Fonts',
3150 'Allan' => 'Google Fonts',
3151 'Allerta' => 'Google Fonts',
3152 'Allerta Stencil' => 'Google Fonts',
3153 'Allura' => 'Google Fonts',
3154 'Almendra' => 'Google Fonts',
3155 'Almendra Display' => 'Google Fonts',
3156 'Almendra SC' => 'Google Fonts',
3157 'Amarante' => 'Google Fonts',
3158 'Amaranth' => 'Google Fonts',
3159 'Amatic SC' => 'Google Fonts',
3160 'Amethysta' => 'Google Fonts',
3161 'Amiko' => 'Google Fonts',
3162 'Amiri' => 'Google Fonts',
3163 'Amita' => 'Google Fonts',
3164 'Anaheim' => 'Google Fonts',
3165 'Andada' => 'Google Fonts',
3166 'Andika' => 'Google Fonts',
3167 'Angkor' => 'Google Fonts',
3168 'Annie Use Your Telescope' => 'Google Fonts',
3169 'Anonymous Pro' => 'Google Fonts',
3170 'Antic' => 'Google Fonts',
3171 'Antic Didone' => 'Google Fonts',
3172 'Antic Slab' => 'Google Fonts',
3173 'Anton' => 'Google Fonts',
3174 'Arapey' => 'Google Fonts',
3175 'Arbutus' => 'Google Fonts',
3176 'Arbutus Slab' => 'Google Fonts',
3177 'Architects Daughter' => 'Google Fonts',
3178 'Archivo' => 'Google Fonts',
3179 'Archivo Black' => 'Google Fonts',
3180 'Archivo Narrow' => 'Google Fonts',
3181 'Aref Ruqaa' => 'Google Fonts',
3182 'Arima Madurai' => 'Google Fonts',
3183 'Arimo' => 'Google Fonts',
3184 'Arizonia' => 'Google Fonts',
3185 'Armata' => 'Google Fonts',
3186 'Arsenal' => 'Google Fonts',
3187 'Artifika' => 'Google Fonts',
3188 'Arvo' => 'Google Fonts',
3189 'Arya' => 'Google Fonts',
3190 'Asap' => 'Google Fonts',
3191 'Asap Condensed' => 'Google Fonts',
3192 'Asar' => 'Google Fonts',
3193 'Asset' => 'Google Fonts',
3194 'Assistant' => 'Google Fonts',
3195 'Astloch' => 'Google Fonts',
3196 'Asul' => 'Google Fonts',
3197 'Athiti' => 'Google Fonts',
3198 'Atma' => 'Google Fonts',
3199 'Atomic Age' => 'Google Fonts',
3200 'Aubrey' => 'Google Fonts',
3201 'Audiowide' => 'Google Fonts',
3202 'Autour One' => 'Google Fonts',
3203 'Average' => 'Google Fonts',
3204 'Average Sans' => 'Google Fonts',
3205 'Averia Gruesa Libre' => 'Google Fonts',
3206 'Averia Libre' => 'Google Fonts',
3207 'Averia Sans Libre' => 'Google Fonts',
3208 'Averia Serif Libre' => 'Google Fonts',
3209 'Bad Script' => 'Google Fonts',
3210 'Bahiana' => 'Google Fonts',
3211 'Bai Jamjuree' => 'Google Fonts',
3212 'Baloo' => 'Google Fonts',
3213 'Baloo Bhai' => 'Google Fonts',
3214 'Baloo Bhaijaan' => 'Google Fonts',
3215 'Baloo Bhaina' => 'Google Fonts',
3216 'Baloo Chettan' => 'Google Fonts',
3217 'Baloo Da' => 'Google Fonts',
3218 'Baloo Paaji' => 'Google Fonts',
3219 'Baloo Tamma' => 'Google Fonts',
3220 'Baloo Tammudu' => 'Google Fonts',
3221 'Baloo Thambi' => 'Google Fonts',
3222 'Balthazar' => 'Google Fonts',
3223 'Bangers' => 'Google Fonts',
3224 'Barlow' => 'Google Fonts',
3225 'Barlow Condensed' => 'Google Fonts',
3226 'Barlow Semi Condensed' => 'Google Fonts',
3227 'Barrio' => 'Google Fonts',
3228 'Basic' => 'Google Fonts',
3229 'Battambang' => 'Google Fonts',
3230 'Baumans' => 'Google Fonts',
3231 'Bayon' => 'Google Fonts',
3232 'Belgrano' => 'Google Fonts',
3233 'Bellefair' => 'Google Fonts',
3234 'Belleza' => 'Google Fonts',
3235 'BenchNine' => 'Google Fonts',
3236 'Bentham' => 'Google Fonts',
3237 'Berkshire Swash' => 'Google Fonts',
3238 'Bevan' => 'Google Fonts',
3239 'Bigelow Rules' => 'Google Fonts',
3240 'Bigshot One' => 'Google Fonts',
3241 'Bilbo' => 'Google Fonts',
3242 'Bilbo Swash Caps' => 'Google Fonts',
3243 'BioRhyme' => 'Google Fonts',
3244 'BioRhyme Expanded' => 'Google Fonts',
3245 'Biryani' => 'Google Fonts',
3246 'Bitter' => 'Google Fonts',
3247 'Black And White Picture' => 'Google Fonts',
3248 'Black Han Sans' => 'Google Fonts',
3249 'Black Ops One' => 'Google Fonts',
3250 'Bokor' => 'Google Fonts',
3251 'Bonbon' => 'Google Fonts',
3252 'Boogaloo' => 'Google Fonts',
3253 'Bowlby One' => 'Google Fonts',
3254 'Bowlby One SC' => 'Google Fonts',
3255 'Brawler' => 'Google Fonts',
3256 'Bree Serif' => 'Google Fonts',
3257 'Bubblegum Sans' => 'Google Fonts',
3258 'Bubbler One' => 'Google Fonts',
3259 'Buda' => 'Google Fonts',
3260 'Buenard' => 'Google Fonts',
3261 'Bungee' => 'Google Fonts',
3262 'Bungee Hairline' => 'Google Fonts',
3263 'Bungee Inline' => 'Google Fonts',
3264 'Bungee Outline' => 'Google Fonts',
3265 'Bungee Shade' => 'Google Fonts',
3266 'Butcherman' => 'Google Fonts',
3267 'Butterfly Kids' => 'Google Fonts',
3268 'Cabin' => 'Google Fonts',
3269 'Cabin Condensed' => 'Google Fonts',
3270 'Cabin Sketch' => 'Google Fonts',
3271 'Caesar Dressing' => 'Google Fonts',
3272 'Cagliostro' => 'Google Fonts',
3273 'Cairo' => 'Google Fonts',
3274 'Calligraffitti' => 'Google Fonts',
3275 'Cambay' => 'Google Fonts',
3276 'Cambo' => 'Google Fonts',
3277 'Candal' => 'Google Fonts',
3278 'Cantarell' => 'Google Fonts',
3279 'Cantata One' => 'Google Fonts',
3280 'Cantora One' => 'Google Fonts',
3281 'Capriola' => 'Google Fonts',
3282 'Cardo' => 'Google Fonts',
3283 'Carme' => 'Google Fonts',
3284 'Carrois Gothic' => 'Google Fonts',
3285 'Carrois Gothic SC' => 'Google Fonts',
3286 'Carter One' => 'Google Fonts',
3287 'Catamaran' => 'Google Fonts',
3288 'Caudex' => 'Google Fonts',
3289 'Caveat' => 'Google Fonts',
3290 'Caveat Brush' => 'Google Fonts',
3291 'Cedarville Cursive' => 'Google Fonts',
3292 'Ceviche One' => 'Google Fonts',
3293 'Chakra Petch' => 'Google Fonts',
3294 'Changa' => 'Google Fonts',
3295 'Changa One' => 'Google Fonts',
3296 'Chango' => 'Google Fonts',
3297 'Charmonman' => 'Google Fonts',
3298 'Chathura' => 'Google Fonts',
3299 'Chau Philomene One' => 'Google Fonts',
3300 'Chela One' => 'Google Fonts',
3301 'Chelsea Market' => 'Google Fonts',
3302 'Chenla' => 'Google Fonts',
3303 'Cherry Cream Soda' => 'Google Fonts',
3304 'Cherry Swash' => 'Google Fonts',
3305 'Chewy' => 'Google Fonts',
3306 'Chicle' => 'Google Fonts',
3307 'Chivo' => 'Google Fonts',
3308 'Chonburi' => 'Google Fonts',
3309 'Cinzel' => 'Google Fonts',
3310 'Cinzel Decorative' => 'Google Fonts',
3311 'Clicker Script' => 'Google Fonts',
3312 'Coda' => 'Google Fonts',
3313 'Coda Caption' => 'Google Fonts',
3314 'Codystar' => 'Google Fonts',
3315 'Coiny' => 'Google Fonts',
3316 'Combo' => 'Google Fonts',
3317 'Comfortaa' => 'Google Fonts',
3318 'Coming Soon' => 'Google Fonts',
3319 'Concert One' => 'Google Fonts',
3320 'Condiment' => 'Google Fonts',
3321 'Content' => 'Google Fonts',
3322 'Contrail One' => 'Google Fonts',
3323 'Convergence' => 'Google Fonts',
3324 'Cookie' => 'Google Fonts',
3325 'Copse' => 'Google Fonts',
3326 'Corben' => 'Google Fonts',
3327 'Cormorant' => 'Google Fonts',
3328 'Cormorant Garamond' => 'Google Fonts',
3329 'Cormorant Infant' => 'Google Fonts',
3330 'Cormorant SC' => 'Google Fonts',
3331 'Cormorant Unicase' => 'Google Fonts',
3332 'Cormorant Upright' => 'Google Fonts',
3333 'Courgette' => 'Google Fonts',
3334 'Cousine' => 'Google Fonts',
3335 'Coustard' => 'Google Fonts',
3336 'Covered By Your Grace' => 'Google Fonts',
3337 'Crafty Girls' => 'Google Fonts',
3338 'Creepster' => 'Google Fonts',
3339 'Crete Round' => 'Google Fonts',
3340 'Crimson Text' => 'Google Fonts',
3341 'Croissant One' => 'Google Fonts',
3342 'Crushed' => 'Google Fonts',
3343 'Cuprum' => 'Google Fonts',
3344 'Cute Font' => 'Google Fonts',
3345 'Cutive' => 'Google Fonts',
3346 'Cutive Mono' => 'Google Fonts',
3347 'Damion' => 'Google Fonts',
3348 'Dancing Script' => 'Google Fonts',
3349 'Dangrek' => 'Google Fonts',
3350 'David Libre' => 'Google Fonts',
3351 'Dawning of a New Day' => 'Google Fonts',
3352 'Days One' => 'Google Fonts',
3353 'Dekko' => 'Google Fonts',
3354 'Delius' => 'Google Fonts',
3355 'Delius Swash Caps' => 'Google Fonts',
3356 'Delius Unicase' => 'Google Fonts',
3357 'Della Respira' => 'Google Fonts',
3358 'Denk One' => 'Google Fonts',
3359 'Devonshire' => 'Google Fonts',
3360 'Dhurjati' => 'Google Fonts',
3361 'Didact Gothic' => 'Google Fonts',
3362 'Diplomata' => 'Google Fonts',
3363 'Diplomata SC' => 'Google Fonts',
3364 'Do Hyeon' => 'Google Fonts',
3365 'Dokdo' => 'Google Fonts',
3366 'Domine' => 'Google Fonts',
3367 'Donegal One' => 'Google Fonts',
3368 'Doppio One' => 'Google Fonts',
3369 'Dorsa' => 'Google Fonts',
3370 'Dosis' => 'Google Fonts',
3371 'Dr Sugiyama' => 'Google Fonts',
3372 'Droid Arabic Kufi' => 'Google Fonts', // Hack for Google Early Access.
3373 'Droid Arabic Naskh' => 'Google Fonts', // Hack for Google Early Access.
3374 'Duru Sans' => 'Google Fonts',
3375 'Dynalight' => 'Google Fonts',
3376 'EB Garamond' => 'Google Fonts',
3377 'Eagle Lake' => 'Google Fonts',
3378 'East Sea Dokdo' => 'Google Fonts',
3379 'Eater' => 'Google Fonts',
3380 'Economica' => 'Google Fonts',
3381 'Eczar' => 'Google Fonts',
3382 'El Messiri' => 'Google Fonts',
3383 'Electrolize' => 'Google Fonts',
3384 'Elsie' => 'Google Fonts',
3385 'Elsie Swash Caps' => 'Google Fonts',
3386 'Emblema One' => 'Google Fonts',
3387 'Emilys Candy' => 'Google Fonts',
3388 'Encode Sans' => 'Google Fonts',
3389 'Encode Sans Condensed' => 'Google Fonts',
3390 'Encode Sans Expanded' => 'Google Fonts',
3391 'Encode Sans Semi Condensed' => 'Google Fonts',
3392 'Encode Sans Semi Expanded' => 'Google Fonts',
3393 'Engagement' => 'Google Fonts',
3394 'Englebert' => 'Google Fonts',
3395 'Enriqueta' => 'Google Fonts',
3396 'Erica One' => 'Google Fonts',
3397 'Esteban' => 'Google Fonts',
3398 'Euphoria Script' => 'Google Fonts',
3399 'Ewert' => 'Google Fonts',
3400 'Exo' => 'Google Fonts',
3401 'Exo 2' => 'Google Fonts',
3402 'Expletus Sans' => 'Google Fonts',
3403 'Fahkwang' => 'Google Fonts',
3404 'Fanwood Text' => 'Google Fonts',
3405 'Farsan' => 'Google Fonts',
3406 'Fascinate' => 'Google Fonts',
3407 'Fascinate Inline' => 'Google Fonts',
3408 'Faster One' => 'Google Fonts',
3409 'Fasthand' => 'Google Fonts',
3410 'Fauna One' => 'Google Fonts',
3411 'Faustina' => 'Google Fonts',
3412 'Federant' => 'Google Fonts',
3413 'Federo' => 'Google Fonts',
3414 'Felipa' => 'Google Fonts',
3415 'Fenix' => 'Google Fonts',
3416 'Finger Paint' => 'Google Fonts',
3417 'Fira Mono' => 'Google Fonts',
3418 'Fira Sans' => 'Google Fonts',
3419 'Fira Sans Condensed' => 'Google Fonts',
3420 'Fira Sans Extra Condensed' => 'Google Fonts',
3421 'Fjalla One' => 'Google Fonts',
3422 'Fjord One' => 'Google Fonts',
3423 'Flamenco' => 'Google Fonts',
3424 'Flavors' => 'Google Fonts',
3425 'Fondamento' => 'Google Fonts',
3426 'Fontdiner Swanky' => 'Google Fonts',
3427 'Forum' => 'Google Fonts',
3428 'Francois One' => 'Google Fonts',
3429 'Frank Ruhl Libre' => 'Google Fonts',
3430 'Freckle Face' => 'Google Fonts',
3431 'Fredericka the Great' => 'Google Fonts',
3432 'Fredoka One' => 'Google Fonts',
3433 'Freehand' => 'Google Fonts',
3434 'Fresca' => 'Google Fonts',
3435 'Frijole' => 'Google Fonts',
3436 'Fruktur' => 'Google Fonts',
3437 'Fugaz One' => 'Google Fonts',
3438 'GFS Didot' => 'Google Fonts',
3439 'GFS Neohellenic' => 'Google Fonts',
3440 'Gabriela' => 'Google Fonts',
3441 'Gaegu' => 'Google Fonts',
3442 'Gafata' => 'Google Fonts',
3443 'Galada' => 'Google Fonts',
3444 'Galdeano' => 'Google Fonts',
3445 'Galindo' => 'Google Fonts',
3446 'Gamja Flower' => 'Google Fonts',
3447 'Gentium Basic' => 'Google Fonts',
3448 'Gentium Book Basic' => 'Google Fonts',
3449 'Geo' => 'Google Fonts',
3450 'Geostar' => 'Google Fonts',
3451 'Geostar Fill' => 'Google Fonts',
3452 'Germania One' => 'Google Fonts',
3453 'Gidugu' => 'Google Fonts',
3454 'Gilda Display' => 'Google Fonts',
3455 'Give You Glory' => 'Google Fonts',
3456 'Glass Antiqua' => 'Google Fonts',
3457 'Glegoo' => 'Google Fonts',
3458 'Gloria Hallelujah' => 'Google Fonts',
3459 'Goblin One' => 'Google Fonts',
3460 'Gochi Hand' => 'Google Fonts',
3461 'Gorditas' => 'Google Fonts',
3462 'Gothic A1' => 'Google Fonts',
3463 'Goudy Bookletter 1911' => 'Google Fonts',
3464 'Graduate' => 'Google Fonts',
3465 'Grand Hotel' => 'Google Fonts',
3466 'Gravitas One' => 'Google Fonts',
3467 'Great Vibes' => 'Google Fonts',
3468 'Griffy' => 'Google Fonts',
3469 'Gruppo' => 'Google Fonts',
3470 'Gudea' => 'Google Fonts',
3471 'Gugi' => 'Google Fonts',
3472 'Gurajada' => 'Google Fonts',
3473 'Habibi' => 'Google Fonts',
3474 'Halant' => 'Google Fonts',
3475 'Hammersmith One' => 'Google Fonts',
3476 'Hanalei' => 'Google Fonts',
3477 'Hanalei Fill' => 'Google Fonts',
3478 'Handlee' => 'Google Fonts',
3479 'Hanuman' => 'Google Fonts',
3480 'Happy Monkey' => 'Google Fonts',
3481 'Harmattan' => 'Google Fonts',
3482 'Headland One' => 'Google Fonts',
3483 'Heebo' => 'Google Fonts',
3484 'Henny Penny' => 'Google Fonts',
3485 'Herr Von Muellerhoff' => 'Google Fonts',
3486 'Hi Melody' => 'Google Fonts',
3487 'Hind' => 'Google Fonts',
3488 'Hind Guntur' => 'Google Fonts',
3489 'Hind Madurai' => 'Google Fonts',
3490 'Hind Siliguri' => 'Google Fonts',
3491 'Hind Vadodara' => 'Google Fonts',
3492 'Holtwood One SC' => 'Google Fonts',
3493 'Homemade Apple' => 'Google Fonts',
3494 'Homenaje' => 'Google Fonts',
3495 'IBM Plex Mono' => 'Google Fonts',
3496 'IBM Plex Sans' => 'Google Fonts',
3497 'IBM Plex Sans Condensed' => 'Google Fonts',
3498 'IBM Plex Serif' => 'Google Fonts',
3499 'IM Fell DW Pica' => 'Google Fonts',
3500 'IM Fell DW Pica SC' => 'Google Fonts',
3501 'IM Fell Double Pica' => 'Google Fonts',
3502 'IM Fell Double Pica SC' => 'Google Fonts',
3503 'IM Fell English' => 'Google Fonts',
3504 'IM Fell English SC' => 'Google Fonts',
3505 'IM Fell French Canon' => 'Google Fonts',
3506 'IM Fell French Canon SC' => 'Google Fonts',
3507 'IM Fell Great Primer' => 'Google Fonts',
3508 'IM Fell Great Primer SC' => 'Google Fonts',
3509 'Iceberg' => 'Google Fonts',
3510 'Iceland' => 'Google Fonts',
3511 'Imprima' => 'Google Fonts',
3512 'Inconsolata' => 'Google Fonts',
3513 'Inder' => 'Google Fonts',
3514 'Indie Flower' => 'Google Fonts',
3515 'Inika' => 'Google Fonts',
3516 'Inknut Antiqua' => 'Google Fonts',
3517 'Irish Grover' => 'Google Fonts',
3518 'Istok Web' => 'Google Fonts',
3519 'Italiana' => 'Google Fonts',
3520 'Italianno' => 'Google Fonts',
3521 'Itim' => 'Google Fonts',
3522 'Jacques Francois' => 'Google Fonts',
3523 'Jacques Francois Shadow' => 'Google Fonts',
3524 'Jaldi' => 'Google Fonts',
3525 'Jim Nightshade' => 'Google Fonts',
3526 'Jockey One' => 'Google Fonts',
3527 'Jolly Lodger' => 'Google Fonts',
3528 'Jomhuria' => 'Google Fonts',
3529 'Josefin Sans' => 'Google Fonts',
3530 'Josefin Slab' => 'Google Fonts',
3531 'Joti One' => 'Google Fonts',
3532 'Jua' => 'Google Fonts',
3533 'Judson' => 'Google Fonts',
3534 'Julee' => 'Google Fonts',
3535 'Julius Sans One' => 'Google Fonts',
3536 'Junge' => 'Google Fonts',
3537 'Jura' => 'Google Fonts',
3538 'Just Another Hand' => 'Google Fonts',
3539 'Just Me Again Down Here' => 'Google Fonts',
3540 'K2D' => 'Google Fonts',
3541 'Kadwa' => 'Google Fonts',
3542 'Kalam' => 'Google Fonts',
3543 'Kameron' => 'Google Fonts',
3544 'Kanit' => 'Google Fonts',
3545 'Kantumruy' => 'Google Fonts',
3546 'Karla' => 'Google Fonts',
3547 'Karma' => 'Google Fonts',
3548 'Katibeh' => 'Google Fonts',
3549 'Kaushan Script' => 'Google Fonts',
3550 'Kavivanar' => 'Google Fonts',
3551 'Kavoon' => 'Google Fonts',
3552 'Kdam Thmor' => 'Google Fonts',
3553 'Keania One' => 'Google Fonts',
3554 'Kelly Slab' => 'Google Fonts',
3555 'Kenia' => 'Google Fonts',
3556 'Khand' => 'Google Fonts',
3557 'Khmer' => 'Google Fonts',
3558 'Khula' => 'Google Fonts',
3559 'Kirang Haerang' => 'Google Fonts',
3560 'Kite One' => 'Google Fonts',
3561 'Knewave' => 'Google Fonts',
3562 'KoHo' => 'Google Fonts',
3563 'Kodchasan' => 'Google Fonts',
3564 'Kosugi' => 'Google Fonts',
3565 'Kosugi Maru' => 'Google Fonts',
3566 'Kotta One' => 'Google Fonts',
3567 'Koulen' => 'Google Fonts',
3568 'Kranky' => 'Google Fonts',
3569 'Kreon' => 'Google Fonts',
3570 'Kristi' => 'Google Fonts',
3571 'Krona One' => 'Google Fonts',
3572 'Krub' => 'Google Fonts',
3573 'Kumar One' => 'Google Fonts',
3574 'Kumar One Outline' => 'Google Fonts',
3575 'Kurale' => 'Google Fonts',
3576 'La Belle Aurore' => 'Google Fonts',
3577 'Laila' => 'Google Fonts',
3578 'Lakki Reddy' => 'Google Fonts',
3579 'Lalezar' => 'Google Fonts',
3580 'Lancelot' => 'Google Fonts',
3581 'Lateef' => 'Google Fonts',
3582 'Lato' => 'Google Fonts',
3583 'League Script' => 'Google Fonts',
3584 'Leckerli One' => 'Google Fonts',
3585 'Ledger' => 'Google Fonts',
3586 'Lekton' => 'Google Fonts',
3587 'Lemon' => 'Google Fonts',
3588 'Lemonada' => 'Google Fonts',
3589 'Libre Barcode 128' => 'Google Fonts',
3590 'Libre Barcode 128 Text' => 'Google Fonts',
3591 'Libre Barcode 39' => 'Google Fonts',
3592 'Libre Barcode 39 Extended' => 'Google Fonts',
3593 'Libre Barcode 39 Extended Text' => 'Google Fonts',
3594 'Libre Barcode 39 Text' => 'Google Fonts',
3595 'Libre Baskerville' => 'Google Fonts',
3596 'Libre Franklin' => 'Google Fonts',
3597 'Life Savers' => 'Google Fonts',
3598 'Lilita One' => 'Google Fonts',
3599 'Lily Script One' => 'Google Fonts',
3600 'Limelight' => 'Google Fonts',
3601 'Linden Hill' => 'Google Fonts',
3602 'Lobster' => 'Google Fonts',
3603 'Lobster Two' => 'Google Fonts',
3604 'Londrina Outline' => 'Google Fonts',
3605 'Londrina Shadow' => 'Google Fonts',
3606 'Londrina Sketch' => 'Google Fonts',
3607 'Londrina Solid' => 'Google Fonts',
3608 'Lora' => 'Google Fonts',
3609 'Love Ya Like A Sister' => 'Google Fonts',
3610 'Loved by the King' => 'Google Fonts',
3611 'Lovers Quarrel' => 'Google Fonts',
3612 'Luckiest Guy' => 'Google Fonts',
3613 'Lusitana' => 'Google Fonts',
3614 'Lustria' => 'Google Fonts',
3615 'M PLUS 1p' => 'Google Fonts',
3616 'M PLUS Rounded 1c' => 'Google Fonts',
3617 'Macondo' => 'Google Fonts',
3618 'Macondo Swash Caps' => 'Google Fonts',
3619 'Mada' => 'Google Fonts',
3620 'Magra' => 'Google Fonts',
3621 'Maiden Orange' => 'Google Fonts',
3622 'Maitree' => 'Google Fonts',
3623 'Mako' => 'Google Fonts',
3624 'Mali' => 'Google Fonts',
3625 'Mallanna' => 'Google Fonts',
3626 'Mandali' => 'Google Fonts',
3627 'Manuale' => 'Google Fonts',
3628 'Marcellus' => 'Google Fonts',
3629 'Marcellus SC' => 'Google Fonts',
3630 'Marck Script' => 'Google Fonts',
3631 'Margarine' => 'Google Fonts',
3632 'Markazi Text' => 'Google Fonts',
3633 'Marko One' => 'Google Fonts',
3634 'Marmelad' => 'Google Fonts',
3635 'Martel' => 'Google Fonts',
3636 'Martel Sans' => 'Google Fonts',
3637 'Marvel' => 'Google Fonts',
3638 'Mate' => 'Google Fonts',
3639 'Mate SC' => 'Google Fonts',
3640 'Maven Pro' => 'Google Fonts',
3641 'McLaren' => 'Google Fonts',
3642 'Meddon' => 'Google Fonts',
3643 'MedievalSharp' => 'Google Fonts',
3644 'Medula One' => 'Google Fonts',
3645 'Meera Inimai' => 'Google Fonts',
3646 'Megrim' => 'Google Fonts',
3647 'Meie Script' => 'Google Fonts',
3648 'Merienda' => 'Google Fonts',
3649 'Merienda One' => 'Google Fonts',
3650 'Merriweather' => 'Google Fonts',
3651 'Merriweather Sans' => 'Google Fonts',
3652 'Metal' => 'Google Fonts',
3653 'Metal Mania' => 'Google Fonts',
3654 'Metamorphous' => 'Google Fonts',
3655 'Metrophobic' => 'Google Fonts',
3656 'Michroma' => 'Google Fonts',
3657 'Milonga' => 'Google Fonts',
3658 'Miltonian' => 'Google Fonts',
3659 'Miltonian Tattoo' => 'Google Fonts',
3660 'Mina' => 'Google Fonts',
3661 'Miniver' => 'Google Fonts',
3662 'Miriam Libre' => 'Google Fonts',
3663 'Mirza' => 'Google Fonts',
3664 'Miss Fajardose' => 'Google Fonts',
3665 'Mitr' => 'Google Fonts',
3666 'Modak' => 'Google Fonts',
3667 'Modern Antiqua' => 'Google Fonts',
3668 'Mogra' => 'Google Fonts',
3669 'Molengo' => 'Google Fonts',
3670 'Molle' => 'Google Fonts',
3671 'Monda' => 'Google Fonts',
3672 'Monofett' => 'Google Fonts',
3673 'Monoton' => 'Google Fonts',
3674 'Monsieur La Doulaise' => 'Google Fonts',
3675 'Montaga' => 'Google Fonts',
3676 'Montez' => 'Google Fonts',
3677 'Montserrat' => 'Google Fonts',
3678 'Montserrat Alternates' => 'Google Fonts',
3679 'Montserrat Subrayada' => 'Google Fonts',
3680 'Moul' => 'Google Fonts',
3681 'Moulpali' => 'Google Fonts',
3682 'Mountains of Christmas' => 'Google Fonts',
3683 'Mouse Memoirs' => 'Google Fonts',
3684 'Mr Bedfort' => 'Google Fonts',
3685 'Mr Dafoe' => 'Google Fonts',
3686 'Mr De Haviland' => 'Google Fonts',
3687 'Mrs Saint Delafield' => 'Google Fonts',
3688 'Mrs Sheppards' => 'Google Fonts',
3689 'Mukta' => 'Google Fonts',
3690 'Mukta Mahee' => 'Google Fonts',
3691 'Mukta Malar' => 'Google Fonts',
3692 'Mukta Vaani' => 'Google Fonts',
3693 'Muli' => 'Google Fonts',
3694 'Mystery Quest' => 'Google Fonts',
3695 'NTR' => 'Google Fonts',
3696 'Nanum Brush Script' => 'Google Fonts',
3697 'Nanum Gothic' => 'Google Fonts',
3698 'Nanum Gothic Coding' => 'Google Fonts',
3699 'Nanum Myeongjo' => 'Google Fonts',
3700 'Nanum Pen Script' => 'Google Fonts',
3701 'Neucha' => 'Google Fonts',
3702 'Neuton' => 'Google Fonts',
3703 'New Rocker' => 'Google Fonts',
3704 'News Cycle' => 'Google Fonts',
3705 'Niconne' => 'Google Fonts',
3706 'Niramit' => 'Google Fonts',
3707 'Nixie One' => 'Google Fonts',
3708 'Nobile' => 'Google Fonts',
3709 'Nokora' => 'Google Fonts',
3710 'Norican' => 'Google Fonts',
3711 'Nosifer' => 'Google Fonts',
3712 'Notable' => 'Google Fonts',
3713 'Nothing You Could Do' => 'Google Fonts',
3714 'Noticia Text' => 'Google Fonts',
3715 'Noto Kufi Arabic' => 'Google Fonts', // Hack for Google Early Access.
3716 'Noto Naskh Arabic' => 'Google Fonts', // Hack for Google Early Access.
3717 'Noto Sans' => 'Google Fonts',
3718 'Noto Sans Hebrew' => 'Google Fonts', // Hack for Google Early Access.
3719 'Noto Sans JP' => 'Google Fonts',
3720 'Noto Sans KR' => 'Google Fonts',
3721 'Noto Serif' => 'Google Fonts',
3722 'Noto Serif JP' => 'Google Fonts',
3723 'Noto Serif KR' => 'Google Fonts',
3724 'Nova Cut' => 'Google Fonts',
3725 'Nova Flat' => 'Google Fonts',
3726 'Nova Mono' => 'Google Fonts',
3727 'Nova Oval' => 'Google Fonts',
3728 'Nova Round' => 'Google Fonts',
3729 'Nova Script' => 'Google Fonts',
3730 'Nova Slim' => 'Google Fonts',
3731 'Nova Square' => 'Google Fonts',
3732 'Numans' => 'Google Fonts',
3733 'Nunito' => 'Google Fonts',
3734 'Nunito Sans' => 'Google Fonts',
3735 'Odor Mean Chey' => 'Google Fonts',
3736 'Offside' => 'Google Fonts',
3737 'Old Standard TT' => 'Google Fonts',
3738 'Oldenburg' => 'Google Fonts',
3739 'Oleo Script' => 'Google Fonts',
3740 'Oleo Script Swash Caps' => 'Google Fonts',
3741 'Open Sans' => 'Google Fonts',
3742 'Open Sans Condensed' => 'Google Fonts',
3743 'Open Sans Hebrew' => 'Google Fonts', // Hack for Google Early Access.
3744 'Open Sans Hebrew Condensed' => 'Google Fonts', // Hack for Google Early Access.
3745 'Oranienbaum' => 'Google Fonts',
3746 'Orbitron' => 'Google Fonts',
3747 'Oregano' => 'Google Fonts',
3748 'Orienta' => 'Google Fonts',
3749 'Original Surfer' => 'Google Fonts',
3750 'Oswald' => 'Google Fonts',
3751 'Over the Rainbow' => 'Google Fonts',
3752 'Overlock' => 'Google Fonts',
3753 'Overlock SC' => 'Google Fonts',
3754 'Overpass' => 'Google Fonts',
3755 'Overpass Mono' => 'Google Fonts',
3756 'Ovo' => 'Google Fonts',
3757 'Oxygen' => 'Google Fonts',
3758 'Oxygen Mono' => 'Google Fonts',
3759 'PT Mono' => 'Google Fonts',
3760 'PT Sans' => 'Google Fonts',
3761 'PT Sans Caption' => 'Google Fonts',
3762 'PT Sans Narrow' => 'Google Fonts',
3763 'PT Serif' => 'Google Fonts',
3764 'PT Serif Caption' => 'Google Fonts',
3765 'Pacifico' => 'Google Fonts',
3766 'Padauk' => 'Google Fonts',
3767 'Palanquin' => 'Google Fonts',
3768 'Palanquin Dark' => 'Google Fonts',
3769 'Pangolin' => 'Google Fonts',
3770 'Paprika' => 'Google Fonts',
3771 'Parisienne' => 'Google Fonts',
3772 'Passero One' => 'Google Fonts',
3773 'Passion One' => 'Google Fonts',
3774 'Pathway Gothic One' => 'Google Fonts',
3775 'Patrick Hand' => 'Google Fonts',
3776 'Patrick Hand SC' => 'Google Fonts',
3777 'Pattaya' => 'Google Fonts',
3778 'Patua One' => 'Google Fonts',
3779 'Pavanam' => 'Google Fonts',
3780 'Paytone One' => 'Google Fonts',
3781 'Peddana' => 'Google Fonts',
3782 'Peralta' => 'Google Fonts',
3783 'Permanent Marker' => 'Google Fonts',
3784 'Petit Formal Script' => 'Google Fonts',
3785 'Petrona' => 'Google Fonts',
3786 'Philosopher' => 'Google Fonts',
3787 'Piedra' => 'Google Fonts',
3788 'Pinyon Script' => 'Google Fonts',
3789 'Pirata One' => 'Google Fonts',
3790 'Plaster' => 'Google Fonts',
3791 'Play' => 'Google Fonts',
3792 'Playball' => 'Google Fonts',
3793 'Playfair Display' => 'Google Fonts',
3794 'Playfair Display SC' => 'Google Fonts',
3795 'Podkova' => 'Google Fonts',
3796 'Poiret One' => 'Google Fonts',
3797 'Poller One' => 'Google Fonts',
3798 'Poly' => 'Google Fonts',
3799 'Pompiere' => 'Google Fonts',
3800 'Pontano Sans' => 'Google Fonts',
3801 'Poor Story' => 'Google Fonts',
3802 'Poppins' => 'Google Fonts',
3803 'Port Lligat Sans' => 'Google Fonts',
3804 'Port Lligat Slab' => 'Google Fonts',
3805 'Pragati Narrow' => 'Google Fonts',
3806 'Prata' => 'Google Fonts',
3807 'Preahvihear' => 'Google Fonts',
3808 'Press Start 2P' => 'Google Fonts',
3809 'Pridi' => 'Google Fonts',
3810 'Princess Sofia' => 'Google Fonts',
3811 'Prociono' => 'Google Fonts',
3812 'Prompt' => 'Google Fonts',
3813 'Prosto One' => 'Google Fonts',
3814 'Proza Libre' => 'Google Fonts',
3815 'Puritan' => 'Google Fonts',
3816 'Purple Purse' => 'Google Fonts',
3817 'Quando' => 'Google Fonts',
3818 'Quantico' => 'Google Fonts',
3819 'Quattrocento' => 'Google Fonts',
3820 'Quattrocento Sans' => 'Google Fonts',
3821 'Questrial' => 'Google Fonts',
3822 'Quicksand' => 'Google Fonts',
3823 'Quintessential' => 'Google Fonts',
3824 'Qwigley' => 'Google Fonts',
3825 'Racing Sans One' => 'Google Fonts',
3826 'Radley' => 'Google Fonts',
3827 'Rajdhani' => 'Google Fonts',
3828 'Rakkas' => 'Google Fonts',
3829 'Raleway' => 'Google Fonts',
3830 'Raleway Dots' => 'Google Fonts',
3831 'Ramabhadra' => 'Google Fonts',
3832 'Ramaraja' => 'Google Fonts',
3833 'Rambla' => 'Google Fonts',
3834 'Rammetto One' => 'Google Fonts',
3835 'Ranchers' => 'Google Fonts',
3836 'Rancho' => 'Google Fonts',
3837 'Ranga' => 'Google Fonts',
3838 'Rasa' => 'Google Fonts',
3839 'Rationale' => 'Google Fonts',
3840 'Ravi Prakash' => 'Google Fonts',
3841 'Redressed' => 'Google Fonts',
3842 'Reem Kufi' => 'Google Fonts',
3843 'Reenie Beanie' => 'Google Fonts',
3844 'Revalia' => 'Google Fonts',
3845 'Rhodium Libre' => 'Google Fonts',
3846 'Ribeye' => 'Google Fonts',
3847 'Ribeye Marrow' => 'Google Fonts',
3848 'Righteous' => 'Google Fonts',
3849 'Risque' => 'Google Fonts',
3850 'Roboto' => 'Google Fonts',
3851 'Roboto Condensed' => 'Google Fonts',
3852 'Roboto Mono' => 'Google Fonts',
3853 'Roboto Slab' => 'Google Fonts',
3854 'Rochester' => 'Google Fonts',
3855 'Rock Salt' => 'Google Fonts',
3856 'Rokkitt' => 'Google Fonts',
3857 'Romanesco' => 'Google Fonts',
3858 'Ropa Sans' => 'Google Fonts',
3859 'Rosario' => 'Google Fonts',
3860 'Rosarivo' => 'Google Fonts',
3861 'Rouge Script' => 'Google Fonts',
3862 'Rozha One' => 'Google Fonts',
3863 'Rubik' => 'Google Fonts',
3864 'Rubik Mono One' => 'Google Fonts',
3865 'Ruda' => 'Google Fonts',
3866 'Rufina' => 'Google Fonts',
3867 'Ruge Boogie' => 'Google Fonts',
3868 'Ruluko' => 'Google Fonts',
3869 'Rum Raisin' => 'Google Fonts',
3870 'Ruslan Display' => 'Google Fonts',
3871 'Russo One' => 'Google Fonts',
3872 'Ruthie' => 'Google Fonts',
3873 'Rye' => 'Google Fonts',
3874 'Sacramento' => 'Google Fonts',
3875 'Sahitya' => 'Google Fonts',
3876 'Sail' => 'Google Fonts',
3877 'Saira' => 'Google Fonts',
3878 'Saira Condensed' => 'Google Fonts',
3879 'Saira Extra Condensed' => 'Google Fonts',
3880 'Saira Semi Condensed' => 'Google Fonts',
3881 'Salsa' => 'Google Fonts',
3882 'Sanchez' => 'Google Fonts',
3883 'Sancreek' => 'Google Fonts',
3884 'Sansita' => 'Google Fonts',
3885 'Sarala' => 'Google Fonts',
3886 'Sarina' => 'Google Fonts',
3887 'Sarpanch' => 'Google Fonts',
3888 'Satisfy' => 'Google Fonts',
3889 'Sawarabi Gothic' => 'Google Fonts',
3890 'Sawarabi Mincho' => 'Google Fonts',
3891 'Scada' => 'Google Fonts',
3892 'Scheherazade' => 'Google Fonts',
3893 'Schoolbell' => 'Google Fonts',
3894 'Scope One' => 'Google Fonts',
3895 'Seaweed Script' => 'Google Fonts',
3896 'Secular One' => 'Google Fonts',
3897 'Sedgwick Ave' => 'Google Fonts',
3898 'Sedgwick Ave Display' => 'Google Fonts',
3899 'Sevillana' => 'Google Fonts',
3900 'Seymour One' => 'Google Fonts',
3901 'Shadows Into Light' => 'Google Fonts',
3902 'Shadows Into Light Two' => 'Google Fonts',
3903 'Shanti' => 'Google Fonts',
3904 'Share' => 'Google Fonts',
3905 'Share Tech' => 'Google Fonts',
3906 'Share Tech Mono' => 'Google Fonts',
3907 'Shojumaru' => 'Google Fonts',
3908 'Short Stack' => 'Google Fonts',
3909 'Shrikhand' => 'Google Fonts',
3910 'Siemreap' => 'Google Fonts',
3911 'Sigmar One' => 'Google Fonts',
3912 'Signika' => 'Google Fonts',
3913 'Signika Negative' => 'Google Fonts',
3914 'Simonetta' => 'Google Fonts',
3915 'Sintony' => 'Google Fonts',
3916 'Sirin Stencil' => 'Google Fonts',
3917 'Six Caps' => 'Google Fonts',
3918 'Skranji' => 'Google Fonts',
3919 'Slabo 13px' => 'Google Fonts',
3920 'Slabo 27px' => 'Google Fonts',
3921 'Slackey' => 'Google Fonts',
3922 'Smokum' => 'Google Fonts',
3923 'Smythe' => 'Google Fonts',
3924 'Sniglet' => 'Google Fonts',
3925 'Snippet' => 'Google Fonts',
3926 'Snowburst One' => 'Google Fonts',
3927 'Sofadi One' => 'Google Fonts',
3928 'Sofia' => 'Google Fonts',
3929 'Song Myung' => 'Google Fonts',
3930 'Sonsie One' => 'Google Fonts',
3931 'Sorts Mill Goudy' => 'Google Fonts',
3932 'Source Code Pro' => 'Google Fonts',
3933 'Source Sans Pro' => 'Google Fonts',
3934 'Source Serif Pro' => 'Google Fonts',
3935 'Space Mono' => 'Google Fonts',
3936 'Special Elite' => 'Google Fonts',
3937 'Spectral' => 'Google Fonts',
3938 'Spectral SC' => 'Google Fonts',
3939 'Spicy Rice' => 'Google Fonts',
3940 'Spinnaker' => 'Google Fonts',
3941 'Spirax' => 'Google Fonts',
3942 'Squada One' => 'Google Fonts',
3943 'Sree Krushnadevaraya' => 'Google Fonts',
3944 'Sriracha' => 'Google Fonts',
3945 'Srisakdi' => 'Google Fonts',
3946 'Stalemate' => 'Google Fonts',
3947 'Stalinist One' => 'Google Fonts',
3948 'Stardos Stencil' => 'Google Fonts',
3949 'Stint Ultra Condensed' => 'Google Fonts',
3950 'Stint Ultra Expanded' => 'Google Fonts',
3951 'Stoke' => 'Google Fonts',
3952 'Strait' => 'Google Fonts',
3953 'Stylish' => 'Google Fonts',
3954 'Sue Ellen Francisco' => 'Google Fonts',
3955 'Suez One' => 'Google Fonts',
3956 'Sumana' => 'Google Fonts',
3957 'Sunflower' => 'Google Fonts',
3958 'Sunshiney' => 'Google Fonts',
3959 'Supermercado One' => 'Google Fonts',
3960 'Sura' => 'Google Fonts',
3961 'Suranna' => 'Google Fonts',
3962 'Suravaram' => 'Google Fonts',
3963 'Suwannaphum' => 'Google Fonts',
3964 'Swanky and Moo Moo' => 'Google Fonts',
3965 'Syncopate' => 'Google Fonts',
3966 'Tajawal' => 'Google Fonts',
3967 'Tangerine' => 'Google Fonts',
3968 'Taprom' => 'Google Fonts',
3969 'Tauri' => 'Google Fonts',
3970 'Taviraj' => 'Google Fonts',
3971 'Teko' => 'Google Fonts',
3972 'Telex' => 'Google Fonts',
3973 'Tenali Ramakrishna' => 'Google Fonts',
3974 'Tenor Sans' => 'Google Fonts',
3975 'Text Me One' => 'Google Fonts',
3976 'The Girl Next Door' => 'Google Fonts',
3977 'Tienne' => 'Google Fonts',
3978 'Tillana' => 'Google Fonts',
3979 'Timmana' => 'Google Fonts',
3980 'Tinos' => 'Google Fonts',
3981 'Titan One' => 'Google Fonts',
3982 'Titillium Web' => 'Google Fonts',
3983 'Trade Winds' => 'Google Fonts',
3984 'Trirong' => 'Google Fonts',
3985 'Trocchi' => 'Google Fonts',
3986 'Trochut' => 'Google Fonts',
3987 'Trykker' => 'Google Fonts',
3988 'Tulpen One' => 'Google Fonts',
3989 'Ubuntu' => 'Google Fonts',
3990 'Ubuntu Condensed' => 'Google Fonts',
3991 'Ubuntu Mono' => 'Google Fonts',
3992 'Ultra' => 'Google Fonts',
3993 'Uncial Antiqua' => 'Google Fonts',
3994 'Underdog' => 'Google Fonts',
3995 'Unica One' => 'Google Fonts',
3996 'UnifrakturCook' => 'Google Fonts',
3997 'UnifrakturMaguntia' => 'Google Fonts',
3998 'Unkempt' => 'Google Fonts',
3999 'Unlock' => 'Google Fonts',
4000 'Unna' => 'Google Fonts',
4001 'VT323' => 'Google Fonts',
4002 'Vampiro One' => 'Google Fonts',
4003 'Varela' => 'Google Fonts',
4004 'Varela Round' => 'Google Fonts',
4005 'Vast Shadow' => 'Google Fonts',
4006 'Vesper Libre' => 'Google Fonts',
4007 'Vibur' => 'Google Fonts',
4008 'Vidaloka' => 'Google Fonts',
4009 'Viga' => 'Google Fonts',
4010 'Voces' => 'Google Fonts',
4011 'Volkhov' => 'Google Fonts',
4012 'Vollkorn' => 'Google Fonts',
4013 'Vollkorn SC' => 'Google Fonts',
4014 'Voltaire' => 'Google Fonts',
4015 'Waiting for the Sunrise' => 'Google Fonts',
4016 'Wallpoet' => 'Google Fonts',
4017 'Walter Turncoat' => 'Google Fonts',
4018 'Warnes' => 'Google Fonts',
4019 'Wellfleet' => 'Google Fonts',
4020 'Wendy One' => 'Google Fonts',
4021 'Wire One' => 'Google Fonts',
4022 'Work Sans' => 'Google Fonts',
4023 'Yanone Kaffeesatz' => 'Google Fonts',
4024 'Yantramanav' => 'Google Fonts',
4025 'Yatra One' => 'Google Fonts',
4026 'Yellowtail' => 'Google Fonts',
4027 'Yeon Sung' => 'Google Fonts',
4028 'Yeseva One' => 'Google Fonts',
4029 'Yesteryear' => 'Google Fonts',
4030 'Yrsa' => 'Google Fonts',
4031 'Zeyada' => 'Google Fonts',
4032 'Zilla Slab' => 'Google Fonts',
4033 'Zilla Slab Highlight' => 'Google Fonts',
4034 );
4035 }
4036
4037 public function set_default_values_if_not_exists()
4038 {
4039 $options = get_option(WCP_FOLDER_VAR);
4040 $options = empty($options) || !is_array($options) ? array() : $options;
4041 foreach ($options as $option) {
4042 $post_type = self::get_custom_post_type($option);
4043 $terms = get_terms($post_type, array(
4044 'hide_empty' => false,
4045 )
4046 );
4047 if (!empty($terms)) {
4048 foreach ($terms as $term) {
4049 $order = get_term_meta($term->term_id, "wcp_custom_order", true);
4050 if (empty($order) || $order == null) {
4051 update_term_meta($term->term_id, "wcp_custom_order", "1");
4052 }
4053 }
4054 }
4055 }
4056 }
4057
4058 /* Free and Pro major changes */
4059 public function update_popup_status() {
4060 if(!empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'folder_update_popup_status')) {
4061 update_option("folder_intro_box", "hide");
4062 }
4063 echo esc_attr("1");
4064 die;
4065 }
4066
4067 public function check_has_valid_key()
4068 {
4069 /* Free/Pro: checking for key, for Free return 0, for Pro check for Key */
4070 return 0;
4071 }
4072
4073 public function get_license_key_information($licenseKey)
4074 {
4075 return array();
4076 }
4077
4078 public function get_license_key_data($licenseKey = '')
4079 {
4080 return array();
4081 }
4082
4083 public function check_for_license_key()
4084 {
4085 return false;
4086 }
4087 }