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