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