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