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