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