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