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