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