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