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