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