class-affiliate.php
3 years ago
class-polylang.php
3 years ago
class-review-box.php
3 years ago
class-upgrade-box.php
3 years ago
class-wpml.php
3 years ago
folders.class.php
3 years ago
form.class.php
3 years ago
media.replace.php
3 years ago
plugins.class.php
3 years ago
tree.class.php
3 years ago
folders.class.php
6777 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class Folders Main |
| 4 | * |
| 5 | * @author : Premio <contact@premio.io> |
| 6 | * @license : GPL2 |
| 7 | * */ |
| 8 | |
| 9 | if (! defined('ABSPATH')) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | // Free/Pro Class name change |
| 14 | class WCP_Folders |
| 15 | { |
| 16 | |
| 17 | /** |
| 18 | * Instance of Class |
| 19 | * |
| 20 | * @var object $instance Instance of Class |
| 21 | * @since 1.0.0 |
| 22 | * @access public |
| 23 | */ |
| 24 | private static $instance; |
| 25 | |
| 26 | /** |
| 27 | * License key data |
| 28 | * |
| 29 | * @var array $license_key_data License key data |
| 30 | * @since 1.0.0 |
| 31 | * @access public |
| 32 | */ |
| 33 | private static $license_key_data = null; |
| 34 | |
| 35 | /** |
| 36 | * Folders data |
| 37 | * |
| 38 | * @var object $folders Folders data |
| 39 | * @since 1.0.0 |
| 40 | * @access public |
| 41 | */ |
| 42 | private static $folders; |
| 43 | |
| 44 | /** |
| 45 | * Total number of folders |
| 46 | * |
| 47 | * @var integer $tlfs total number of folders |
| 48 | * @since 1.0.0 |
| 49 | * @access public |
| 50 | */ |
| 51 | public $tlfs = 0; |
| 52 | |
| 53 | /** |
| 54 | * Collection on post ids |
| 55 | * |
| 56 | * @var array $postIds collection on post ids |
| 57 | * @since 1.0.0 |
| 58 | * @access public |
| 59 | */ |
| 60 | private static $postIds; |
| 61 | |
| 62 | /** |
| 63 | * Folders Settings |
| 64 | * |
| 65 | * @var array $folderSettings Folders Settings |
| 66 | * @since 1.0.0 |
| 67 | * @access public |
| 68 | */ |
| 69 | private static $folderSettings = false; |
| 70 | |
| 71 | |
| 72 | /** |
| 73 | * Folders Settings |
| 74 | * |
| 75 | * @var array $folders_settings Folders Settings |
| 76 | * @since 1.0.0 |
| 77 | * @access public |
| 78 | */ |
| 79 | var $folders_settings = false; |
| 80 | |
| 81 | |
| 82 | /** |
| 83 | * Define the core functionality of the import data functionality. |
| 84 | * |
| 85 | * Add/Update folders settings |
| 86 | * Add/Update/Remove/List of folders |
| 87 | * Add/Update/Remove/List posts to folders |
| 88 | * Mark/Unmark folders |
| 89 | * Make Sticky/Unsticky folders |
| 90 | * Add content to folders |
| 91 | * Update folder sidebar width |
| 92 | * Filter taxonomies for folders |
| 93 | * Show drag buttons to post/page table |
| 94 | * |
| 95 | * @since 1.0.0 |
| 96 | */ |
| 97 | public function __construct() |
| 98 | { |
| 99 | |
| 100 | spl_autoload_register([$this, 'autoload']); |
| 101 | add_action('init', [$this, 'create_folder_terms'], 15); |
| 102 | add_action('admin_init', [$this, 'folders_register_settings']); |
| 103 | add_action('admin_menu', [$this, 'admin_menu'], 10000); |
| 104 | add_action('admin_enqueue_scripts', [$this, 'folders_admin_styles']); |
| 105 | add_action('admin_enqueue_scripts', [$this, 'folders_admin_scripts']); |
| 106 | add_filter('plugin_action_links_'.WCP_FOLDERS_PLUGIN_BASE, [$this, 'plugin_action_links']); |
| 107 | add_action('admin_footer', [$this, 'admin_footer']); |
| 108 | |
| 109 | add_action('parse_tax_query', [$this, 'taxonomy_archive_exclude_children']); |
| 110 | add_action('admin_footer', [$this, 'admin_footer_for_media']); |
| 111 | |
| 112 | // Save Data |
| 113 | add_action('wp_ajax_wcp_add_new_folder', [$this, 'wcp_add_new_folder']); |
| 114 | // Update Data |
| 115 | add_action('wp_ajax_wcp_update_folder', [$this, 'wcp_update_folder']); |
| 116 | // Remove Data |
| 117 | add_action('wp_ajax_wcp_remove_folder', [$this, 'wcp_remove_folder']); |
| 118 | // Remove Multple Folder |
| 119 | add_action('wp_ajax_wcp_remove_muliple_folder', [$this, 'remove_muliple_folder']); |
| 120 | // Save State Data |
| 121 | add_action('wp_ajax_save_wcp_folder_state', [$this, 'save_wcp_folder_state']); |
| 122 | // Save State Data |
| 123 | add_action('wp_ajax_wcp_save_parent_data', [$this, 'wcp_save_parent_data']); |
| 124 | // Update Parent Data |
| 125 | add_action('wp_ajax_wcp_update_parent_information', [$this, 'wcp_update_parent_information']); |
| 126 | // Update Parent Data |
| 127 | add_action('wp_ajax_wcp_save_folder_order', [$this, 'wcp_save_folder_order']); |
| 128 | // Update Parent Data |
| 129 | add_action('wp_ajax_wcp_mark_un_mark_folder', [$this, 'wcp_mark_un_mark_folder']); |
| 130 | // Update Parent Data |
| 131 | add_action('wp_ajax_wcp_make_sticky_folder', [$this, 'wcp_make_sticky_folder']); |
| 132 | // Update Parent Data |
| 133 | add_action('wp_ajax_wcp_change_post_folder', [$this, 'wcp_change_post_folder']); |
| 134 | // Update Parent Data |
| 135 | add_action('wp_ajax_wcp_change_multiple_post_folder', [$this, 'wcp_change_multiple_post_folder']); |
| 136 | // Update width Data |
| 137 | add_action('wp_ajax_wcp_change_post_width', [$this, 'wcp_change_post_width']); |
| 138 | // Update width Data |
| 139 | add_action('wp_ajax_wcp_change_folder_display_status', [$this, 'wcp_change_folder_display_status']); |
| 140 | // Update width Data |
| 141 | add_action('wp_ajax_wcp_change_all_status', [$this, 'wcp_change_all_status']); |
| 142 | // Update width Data |
| 143 | add_action('wp_ajax_save_folder_last_status', [$this, 'save_folder_last_status']); |
| 144 | // Update width Data |
| 145 | add_action('wp_ajax_wcp_folders_by_order', [$this, 'wcp_folders_by_order']); |
| 146 | // Update width Data |
| 147 | add_action('wp_ajax_wcp_remove_all_folders_data', [$this, 'remove_all_folders_data']); |
| 148 | // Update folders Status |
| 149 | add_action('wp_ajax_wcp_update_folders_uninstall_status', [$this, 'update_folders_uninstall_status']); |
| 150 | // Undo Functionality |
| 151 | add_action('wp_ajax_wcp_undo_folder_changes', [$this, 'wcp_undo_folder_changes']); |
| 152 | self::$folders = 10; |
| 153 | |
| 154 | // Send message on plugin deactivate |
| 155 | add_action('wp_ajax_folder_plugin_deactivate', [ $this, 'folder_plugin_deactivate' ]); |
| 156 | // Update Parent Data |
| 157 | add_action('wp_ajax_wcp_remove_post_folder', [$this, 'wcp_remove_post_folder']); |
| 158 | // Send message on owner |
| 159 | add_action('wp_ajax_wcp_folder_send_message_to_owner', [ $this, 'wcp_folder_send_message_to_owner' ]); |
| 160 | // Get default list |
| 161 | add_action('wp_ajax_premio_check_for_other_folders', [$this, 'premio_check_for_other_folders']); |
| 162 | // Send message on owner |
| 163 | add_action('wp_ajax_wcp_get_default_list', [ $this, 'wcp_get_default_list' ]); |
| 164 | // Get default list |
| 165 | add_action('wp_ajax_get_folders_default_list', [ $this, 'get_folders_default_list' ]); |
| 166 | // Auto select folder for new page, post |
| 167 | add_action('new_to_auto-draft', [$this, 'new_to_auto_draft'], 10); |
| 168 | // for media |
| 169 | add_action('restrict_manage_posts', [$this, 'output_list_table_filters'], 10, 2); |
| 170 | add_filter('pre_get_posts', [$this, 'filter_attachments_list']); |
| 171 | add_action('wp_enqueue_media', [$this, 'output_backbone_view_filters']); |
| 172 | add_filter('ajax_query_attachments_args', [$this, 'filter_attachments_grid']); |
| 173 | add_filter('add_attachment', [$this, 'save_media_terms']); |
| 174 | |
| 175 | // to filter un assigned items |
| 176 | add_filter('pre_get_posts', [$this, 'filter_record_list']); |
| 177 | add_filter('pre-upload-ui', [$this, 'show_dropdown_on_media_screen']); |
| 178 | add_action('add_attachment', [$this, 'add_attachment_category']); |
| 179 | |
| 180 | $options = get_option("folders_settings"); |
| 181 | |
| 182 | $options = is_array($options) ? $options : []; |
| 183 | |
| 184 | if (in_array("post", $options)) { |
| 185 | add_filter('manage_posts_columns', [$this, 'wcp_manage_columns_head']); |
| 186 | add_action('manage_posts_custom_column', [$this, 'wcp_manage_columns_content'], 10, 2); |
| 187 | add_filter('bulk_actions-edit-post', [$this, 'custom_bulk_action' ]); |
| 188 | } |
| 189 | |
| 190 | if (in_array("page", $options)) { |
| 191 | add_filter('manage_page_posts_columns', [$this, 'wcp_manage_columns_head']); |
| 192 | add_action('manage_page_posts_custom_column', [$this, 'wcp_manage_columns_content'], 10, 2); |
| 193 | add_filter('bulk_actions-edit-page', [$this, 'custom_bulk_action' ]); |
| 194 | } |
| 195 | |
| 196 | if (in_array("attachment", $options)) { |
| 197 | add_filter('manage_media_columns', [$this, 'wcp_manage_columns_head']); |
| 198 | add_action('manage_media_custom_column', [$this, 'wcp_manage_columns_content'], 10, 2); |
| 199 | // add_filter('bulk_actions-edit-media', array($this, 'custom_bulk_action' )); |
| 200 | } |
| 201 | |
| 202 | foreach ($options as $option) { |
| 203 | if ($option != "post" && $option != "page" && $option != "attachment") { |
| 204 | add_filter('manage_edit-'.$option.'_columns', [$this, 'wcp_manage_columns_head'], 99999); |
| 205 | add_action('manage_'.$option.'_posts_custom_column', [$this, 'wcp_manage_columns_content'], 2, 2); |
| 206 | add_filter('bulk_actions-edit-'.$option, [$this, 'custom_bulk_action' ]); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | // check for default folders |
| 211 | add_filter('pre_get_posts', [$this, 'check_for_default_folders']); |
| 212 | |
| 213 | add_action("wp_ajax_folder_update_status", [$this, 'folder_update_status']); |
| 214 | |
| 215 | // load language files |
| 216 | add_action('plugins_loaded', [ $this, 'folders_text' ]); |
| 217 | |
| 218 | add_action("wp_ajax_folder_update_popup_status", [$this, 'folder_update_popup_status']); |
| 219 | |
| 220 | add_action("wp_ajax_premio_hide_child_popup", [$this, 'premio_hide_child_popup']); |
| 221 | |
| 222 | add_action("wp_ajax_wcp_update_folders_import_status", [$this, 'update_folders_import_status']); |
| 223 | |
| 224 | add_filter('get_terms', [ $this, 'get_terms_filter_without_trash'], 10, 3); |
| 225 | |
| 226 | add_filter('mla_media_modal_query_final_terms', [ $this, 'media_modal_query_final_terms'], 10, 3); |
| 227 | |
| 228 | // reset count when post/page updated |
| 229 | add_action('deleted_term_relationships', [$this, 'update_folder_term_relationships'], 10, 3); |
| 230 | |
| 231 | add_action('added_term_relationship', [$this, 'update_folder_new_term_relationships'], 10, 3); |
| 232 | |
| 233 | add_action('set_object_terms', [$this, 'set_object_terms_for_folders'], 10, 6); |
| 234 | |
| 235 | /* |
| 236 | * To Remove Attachment |
| 237 | * */ |
| 238 | |
| 239 | add_action('wp_trash_post', [$this, "wcp_delete_post"]); |
| 240 | add_action('before_delete_post', [$this, "wcp_delete_post"]); |
| 241 | |
| 242 | /* |
| 243 | * Hide Folder CTA |
| 244 | * */ |
| 245 | add_action('wp_ajax_hide_folders_cta', [$this, 'hide_folders_cta']); |
| 246 | |
| 247 | add_action("manage_posts_extra_tablenav", [$this, "manage_posts_extra_fields"]); |
| 248 | |
| 249 | }//end __construct() |
| 250 | |
| 251 | /** |
| 252 | * Add extra params in search |
| 253 | * |
| 254 | * @since 1.0.0 |
| 255 | * @access public |
| 256 | * @return $response |
| 257 | */ |
| 258 | function manage_posts_extra_fields($which) { |
| 259 | global $typenow; |
| 260 | if($which == "top" && !empty($typenow)) { |
| 261 | if ($this->folders_settings === false) { |
| 262 | $this->folders_settings = get_option('folders_settings'); |
| 263 | $this->folders_settings = $this->folders_settings; |
| 264 | $this->folders_settings = is_array($this->folders_settings) ? $this->folders_settings : []; |
| 265 | } |
| 266 | if(in_array($typenow, $this->folders_settings)) { |
| 267 | $folder_type = self::get_custom_post_type($typenow); |
| 268 | if(isset($_REQUEST[$folder_type]) && !empty($_REQUEST[$folder_type])) { |
| 269 | $folder = sanitize_text_field($_REQUEST[$folder_type]); |
| 270 | echo "<input type='hidden' name='".esc_attr($folder_type)."' value='".esc_attr($folder)."' />"; |
| 271 | } else if(isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == "premio_dynamic_folders" && isset($_REQUEST['dynamic_folder'])) { |
| 272 | $dynamic_folder = sanitize_text_field($_REQUEST['dynamic_folder']); |
| 273 | echo "<input type='hidden' name='ajax_action' value='premio_dynamic_folders' />"; |
| 274 | echo "<input type='hidden' name='dynamic_folder' value='".esc_attr($dynamic_folder)."' />"; |
| 275 | } |
| 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Hide CTA button text |
| 282 | * |
| 283 | * @since 1.0.0 |
| 284 | * @access public |
| 285 | * @return $response |
| 286 | */ |
| 287 | public function hide_folders_cta() |
| 288 | { |
| 289 | $response = []; |
| 290 | $response['status'] = 0; |
| 291 | $response['error'] = 0; |
| 292 | $response['data'] = []; |
| 293 | $response['message'] = ""; |
| 294 | $postData = filter_input_array(INPUT_POST); |
| 295 | $errorCounter = 0; |
| 296 | if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 297 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 298 | $errorCounter++; |
| 299 | } else { |
| 300 | $nonce = self::sanitize_options($postData['nonce']); |
| 301 | if (!wp_verify_nonce($nonce, 'hide_folders_cta')) { |
| 302 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 303 | $errorCounter++; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | if ($errorCounter == 0) { |
| 308 | $response['status'] = 1; |
| 309 | add_option("hide_folders_cta", "yes"); |
| 310 | } |
| 311 | |
| 312 | echo json_encode($response); |
| 313 | die; |
| 314 | |
| 315 | }//end hide_folders_cta() |
| 316 | |
| 317 | |
| 318 | /** |
| 319 | * Delete post hook, clear data on post delete |
| 320 | * |
| 321 | * @since 1.0.0 |
| 322 | * @access public |
| 323 | * @return $status |
| 324 | */ |
| 325 | public function wcp_delete_post($postID) |
| 326 | { |
| 327 | delete_transient("premio_folders_without_trash"); |
| 328 | |
| 329 | }//end wcp_delete_post() |
| 330 | |
| 331 | |
| 332 | /** |
| 333 | * Set folders data for post/page ids |
| 334 | * |
| 335 | * @since 1.0.0 |
| 336 | * @access public |
| 337 | * @return $post |
| 338 | */ |
| 339 | public function set_object_terms_for_folders($object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids) |
| 340 | { |
| 341 | if (!empty($object_id)) { |
| 342 | $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash"); |
| 343 | if (!empty($tt_ids) && is_array($tt_ids)) { |
| 344 | foreach ($tt_ids as $term_id) { |
| 345 | $term = get_term($term_id, $taxonomy); |
| 346 | if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) { |
| 347 | unset($trash_folders[$term->term_taxonomy_id]); |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | if (!empty($old_tt_ids) && is_array($old_tt_ids)) { |
| 353 | foreach ($old_tt_ids as $term_id) { |
| 354 | $term = get_term($term_id, $taxonomy); |
| 355 | if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) { |
| 356 | unset($trash_folders[$term->term_taxonomy_id]); |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | if ($initial_trash_folders != $trash_folders) { |
| 362 | delete_transient("premio_folders_without_trash"); |
| 363 | set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS)); |
| 364 | } |
| 365 | }//end if |
| 366 | |
| 367 | }//end set_object_terms_for_folders() |
| 368 | |
| 369 | |
| 370 | /** |
| 371 | * Check for folders settings |
| 372 | * |
| 373 | * @since 1.0.0 |
| 374 | * @access public |
| 375 | * @return $options |
| 376 | */ |
| 377 | public static function check_for_setting($key, $setting, $default="") |
| 378 | { |
| 379 | if (self::$folderSettings === false) { |
| 380 | $options = get_option("premio_folder_options"); |
| 381 | if ($options === false || !is_array($options)) { |
| 382 | $options = []; |
| 383 | } |
| 384 | |
| 385 | self::$folderSettings = $options; |
| 386 | } |
| 387 | |
| 388 | if ($setting == "folders_settings") { |
| 389 | if (isset(self::$folderSettings[$setting]) && is_array(self::$folderSettings[$setting])) { |
| 390 | return in_array($key, self::$folderSettings[$setting]); |
| 391 | } |
| 392 | } else { |
| 393 | if (isset(self::$folderSettings[$setting][$key])) { |
| 394 | return self::$folderSettings[$setting][$key]; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | return false; |
| 399 | |
| 400 | }//end check_for_setting() |
| 401 | |
| 402 | |
| 403 | /** |
| 404 | * Send message to owner on Uninstall |
| 405 | * |
| 406 | * @since 1.0.0 |
| 407 | * @access public |
| 408 | * @return $response |
| 409 | */ |
| 410 | public function update_folders_uninstall_status() |
| 411 | { |
| 412 | $response = []; |
| 413 | $response['status'] = 0; |
| 414 | $response['error'] = 0; |
| 415 | $response['data'] = []; |
| 416 | $response['message'] = ""; |
| 417 | $postData = filter_input_array(INPUT_POST); |
| 418 | $errorCounter = 0; |
| 419 | |
| 420 | if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 421 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 422 | $errorCounter++; |
| 423 | } else { |
| 424 | $nonce = self::sanitize_options($postData['nonce']); |
| 425 | if (!wp_verify_nonce($nonce, 'wcp_folders_uninstall_status')) { |
| 426 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 427 | $errorCounter++; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | if ($errorCounter == 0) { |
| 432 | $status = isset($postData['status']) ? $postData['status'] : ""; |
| 433 | $status = ($status == "on") ? "on" : "off"; |
| 434 | $customize_folders = get_option('customize_folders'); |
| 435 | $customize_folders['remove_folders_when_removed'] = $status; |
| 436 | update_option("customize_folders", $customize_folders); |
| 437 | $response['status'] = 1; |
| 438 | } |
| 439 | |
| 440 | echo json_encode($response); |
| 441 | die; |
| 442 | |
| 443 | }//end update_folders_uninstall_status() |
| 444 | |
| 445 | |
| 446 | /** |
| 447 | * Remove folders data |
| 448 | * |
| 449 | * @since 1.0.0 |
| 450 | * @access public |
| 451 | * @return $response |
| 452 | */ |
| 453 | public function remove_all_folders_data() |
| 454 | { |
| 455 | $response = []; |
| 456 | $response['status'] = 0; |
| 457 | $response['error'] = 0; |
| 458 | $response['data'] = []; |
| 459 | $response['message'] = ""; |
| 460 | $postData = filter_input_array(INPUT_POST); |
| 461 | $errorCounter = 0; |
| 462 | |
| 463 | if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 464 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 465 | $errorCounter++; |
| 466 | } else { |
| 467 | $type = self::sanitize_options($postData['type']); |
| 468 | $nonce = self::sanitize_options($postData['nonce']); |
| 469 | if (!wp_verify_nonce($nonce, 'remove_folders_data')) { |
| 470 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 471 | $errorCounter++; |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | if ($errorCounter == 0) { |
| 476 | self::$folders = 0; |
| 477 | self::remove_folder_by_taxonomy("media_folder"); |
| 478 | self::remove_folder_by_taxonomy("folder"); |
| 479 | self::remove_folder_by_taxonomy("post_folder"); |
| 480 | $post_types = get_post_types([], 'objects'); |
| 481 | $post_array = [ |
| 482 | "page", |
| 483 | "post", |
| 484 | "attachment", |
| 485 | ]; |
| 486 | foreach ($post_types as $post_type) { |
| 487 | if (!in_array($post_type->name, $post_array)) { |
| 488 | self::remove_folder_by_taxonomy($post_type->name.'_folder'); |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | delete_option('default_folders'); |
| 493 | $response['status'] = 1; |
| 494 | $response['data'] = [ |
| 495 | 'items' => self::$folders, |
| 496 | ]; |
| 497 | }//end if |
| 498 | |
| 499 | echo json_encode($response); |
| 500 | die; |
| 501 | |
| 502 | }//end remove_all_folders_data() |
| 503 | |
| 504 | |
| 505 | /** |
| 506 | * Remove folders from poge/post |
| 507 | * |
| 508 | * @since 1.0.0 |
| 509 | * @access public |
| 510 | * @return $folders |
| 511 | */ |
| 512 | public static function remove_folder_by_taxonomy($taxonomy) |
| 513 | { |
| 514 | global $wpdb; |
| 515 | $query = "SELECT * FROM ".$wpdb->term_taxonomy." |
| 516 | LEFT JOIN ".$wpdb->terms." |
| 517 | ON ".$wpdb->term_taxonomy.".term_id = ".$wpdb->terms.".term_id |
| 518 | WHERE ".$wpdb->term_taxonomy.".taxonomy = '%d' |
| 519 | ORDER BY parent ASC"; |
| 520 | $query = $wpdb->prepare($query, $taxonomy); |
| 521 | $folders = $wpdb->get_results($query); |
| 522 | $folders = array_values($folders); |
| 523 | foreach ($folders as $folder) { |
| 524 | $term_id = intval($folder->term_id); |
| 525 | if ($term_id) { |
| 526 | $wpdb->delete($wpdb->prefix.'term_relationships', ['term_taxonomy_id' => $term_id]); |
| 527 | $wpdb->delete($wpdb->prefix.'term_taxonomy', ['term_id' => $term_id]); |
| 528 | $wpdb->delete($wpdb->prefix.'terms', ['term_id' => $term_id]); |
| 529 | $wpdb->delete($wpdb->prefix.'termmeta', ['term_id' => $term_id]); |
| 530 | self::$folders++; |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | }//end remove_folder_by_taxonomy() |
| 535 | |
| 536 | |
| 537 | /** |
| 538 | * Convent Hex color code to RGB code |
| 539 | * |
| 540 | * @since 1.0.0 |
| 541 | * @access public |
| 542 | * @return $rgb |
| 543 | */ |
| 544 | public static function hexToRgb($hex, $alpha=false) |
| 545 | { |
| 546 | $hex = str_replace('#', '', $hex); |
| 547 | $length = strlen($hex); |
| 548 | $rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0)); |
| 549 | $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0)); |
| 550 | $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0)); |
| 551 | if ($alpha) { |
| 552 | $rgb['a'] = $alpha; |
| 553 | } |
| 554 | |
| 555 | return $rgb; |
| 556 | |
| 557 | }//end hexToRgb() |
| 558 | |
| 559 | |
| 560 | /** |
| 561 | * Get folders by folder order |
| 562 | * |
| 563 | * @since 1.0.0 |
| 564 | * @access public |
| 565 | * @return $folders |
| 566 | */ |
| 567 | public function wcp_folders_by_order() |
| 568 | { |
| 569 | $response = []; |
| 570 | $response['status'] = 0; |
| 571 | $response['error'] = 0; |
| 572 | $response['data'] = []; |
| 573 | $response['message'] = ""; |
| 574 | $postData = filter_input_array(INPUT_POST); |
| 575 | $errorCounter = 0; |
| 576 | |
| 577 | if (!isset($postData['order']) || empty($postData['order'])) { |
| 578 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 579 | $errorCounter++; |
| 580 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 581 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 582 | $errorCounter++; |
| 583 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 584 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 585 | $errorCounter++; |
| 586 | } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) { |
| 587 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 588 | $errorCounter++; |
| 589 | } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) { |
| 590 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 591 | $errorCounter++; |
| 592 | } else { |
| 593 | $type = self::sanitize_options($postData['type']); |
| 594 | $nonce = self::sanitize_options($postData['nonce']); |
| 595 | if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) { |
| 596 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 597 | $errorCounter++; |
| 598 | } |
| 599 | }//end if |
| 600 | |
| 601 | if ($errorCounter == 0) { |
| 602 | $response['status'] = 1; |
| 603 | |
| 604 | $order_field = $postData['order']; |
| 605 | |
| 606 | $order_by = ""; |
| 607 | $order = "ASC"; |
| 608 | |
| 609 | if ($order_field == "a-z" || $order_field == "z-a") { |
| 610 | $order_by = 'title'; |
| 611 | if ($order_field == "z-a") { |
| 612 | $order = "DESC"; |
| 613 | } |
| 614 | } else if ($order_field == "n-o" || $order_field == "o-n") { |
| 615 | $order_by = 'ID'; |
| 616 | if ($order_field == "o-n") { |
| 617 | $order = "ASC"; |
| 618 | } else { |
| 619 | $order = "DESC"; |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | if (empty($order_by)) { |
| 624 | $order = ""; |
| 625 | } |
| 626 | |
| 627 | $folder_type = self::get_custom_post_type($postData['type']); |
| 628 | // Do not change: Free/Pro Class name change |
| 629 | $tree_data = WCP_Tree::get_full_tree_data($folder_type, $order_by, $order); |
| 630 | |
| 631 | $response['data'] = $tree_data['string']; |
| 632 | $taxonomies = []; |
| 633 | if ($postData['type'] == "attachment") { |
| 634 | $taxonomies = self::get_terms_hierarchical($folder_type); |
| 635 | } |
| 636 | |
| 637 | $response['terms'] = $taxonomies; |
| 638 | }//end if |
| 639 | |
| 640 | echo json_encode($response); |
| 641 | die; |
| 642 | |
| 643 | }//end wcp_folders_by_order() |
| 644 | |
| 645 | |
| 646 | /** |
| 647 | * Save selected post for page/post/media |
| 648 | * |
| 649 | * @since 1.0.0 |
| 650 | * @access public |
| 651 | * @return $folders |
| 652 | */ |
| 653 | public function save_folder_last_status() |
| 654 | { |
| 655 | $postData = filter_input_array(INPUT_POST); |
| 656 | $error = 0; |
| 657 | if (!isset($postData['post_id']) || empty($postData['post_id'])) { |
| 658 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 659 | $error = 1; |
| 660 | } else if (!isset($postData['post_type']) || empty($postData['type'])) { |
| 661 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 662 | $error = 1; |
| 663 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 664 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 665 | $error = 1; |
| 666 | } else if ($postData['post_type'] == "page" && !current_user_can("edit_pages")) { |
| 667 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 668 | $error = 1; |
| 669 | } else if ($postData['post_type'] != "page" && !current_user_can("edit_posts")) { |
| 670 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 671 | $error = 1; |
| 672 | } |
| 673 | |
| 674 | if ($error == 0) { |
| 675 | $post_type = filter_input(INPUT_POST, 'post_type'); |
| 676 | $post_id = filter_input(INPUT_POST, 'post_id'); |
| 677 | if (!empty($post_type) && !empty($post_id)) { |
| 678 | delete_option("last_folder_status_for".$post_type); |
| 679 | add_option("last_folder_status_for".$post_type, $post_id); |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | }//end save_folder_last_status() |
| 684 | |
| 685 | |
| 686 | /** |
| 687 | * Save selected post for page/post/media |
| 688 | * |
| 689 | * @since 1.0.0 |
| 690 | * @access public |
| 691 | * @return $folders |
| 692 | */ |
| 693 | public function media_modal_query_final_terms($request) |
| 694 | { |
| 695 | $action = $this->getRequestVar("action"); |
| 696 | if ($action == "mla-query-attachments") { |
| 697 | $query = $this->getRequestVar("query"); |
| 698 | if (isset($query['media_folder']) && !empty($query['media_folder'])) { |
| 699 | if ($query['media_folder'] == -1) { |
| 700 | $tax_query = [ |
| 701 | 'taxonomy' => 'media_folder', |
| 702 | 'operator' => 'NOT EXISTS', |
| 703 | ]; |
| 704 | $request['tax_query'] = [$tax_query]; |
| 705 | $request = apply_filters('media_library_organizer_media_filter_attachments', $request, $_REQUEST); |
| 706 | } else { |
| 707 | $request['media_folder'] = $query['media_folder']; |
| 708 | } |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | return $request; |
| 713 | |
| 714 | }//end media_modal_query_final_terms() |
| 715 | |
| 716 | |
| 717 | /** |
| 718 | * Filter folders without trash count |
| 719 | * |
| 720 | * @since 1.0.0 |
| 721 | * @access public |
| 722 | */ |
| 723 | public function get_terms_filter_without_trash($terms, $taxonomies, $args) |
| 724 | { |
| 725 | $isForFolders = 0; |
| 726 | if(!empty($taxonomies) && is_array($taxonomies) && count($taxonomies)){ |
| 727 | foreach ($taxonomies as $taxonomy) { |
| 728 | if (in_array($taxonomy, array("media_folder", "folder", "post_folder"))) { |
| 729 | $isForFolders = 1; |
| 730 | } else { |
| 731 | $folder = substr($taxonomy, -7); |
| 732 | if ($folder == "_folder") { |
| 733 | $isForFolders = 1; |
| 734 | } |
| 735 | } |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | if($isForFolders) { |
| 740 | global $wpdb; |
| 741 | if (!is_array($terms) && count($terms) < 1) { |
| 742 | return $terms; |
| 743 | } |
| 744 | |
| 745 | $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash"); |
| 746 | |
| 747 | if ($trash_folders === false) { |
| 748 | $trash_folders = array(); |
| 749 | $initial_trash_folders = array(); |
| 750 | } |
| 751 | |
| 752 | $post_table = $wpdb->prefix . "posts"; |
| 753 | $term_table = $wpdb->prefix . "term_relationships"; |
| 754 | $options = get_option('folders_settings'); |
| 755 | $option_array = array(); |
| 756 | if (!empty($options)) { |
| 757 | foreach ($options as $option) { |
| 758 | $option_array[] = self::get_custom_post_type($option); |
| 759 | } |
| 760 | } |
| 761 | foreach ($terms as $key => $term) { |
| 762 | if (isset($term->term_id) && isset($term->taxonomy) && !empty($term->taxonomy) && in_array($term->taxonomy, $option_array)) { |
| 763 | $trash_count = null; |
| 764 | if (isset($trash_folders[$term->term_taxonomy_id])) { |
| 765 | $trash_count = $trash_folders[$term->term_taxonomy_id]; |
| 766 | } else { |
| 767 | if (has_filter("premio_folder_item_in_taxonomy")) { |
| 768 | $post_type = ""; |
| 769 | $taxonomy = $term->taxonomy; |
| 770 | |
| 771 | if ($taxonomy == "post_folder") { |
| 772 | $post_type = "post"; |
| 773 | } else if ($taxonomy == "folder") { |
| 774 | $post_type = "page"; |
| 775 | } else if ($taxonomy == "media_folder") { |
| 776 | $post_type = "attachment"; |
| 777 | } else { |
| 778 | $post_type = trim($taxonomy, "'_folder'"); |
| 779 | } |
| 780 | $arg = array( |
| 781 | 'post_type' => $post_type, |
| 782 | 'taxonomy' => $taxonomy, |
| 783 | ); |
| 784 | $trash_count = apply_filters("premio_folder_item_in_taxonomy", $term->term_id, $arg); |
| 785 | } |
| 786 | |
| 787 | if ($trash_count === null) { |
| 788 | //$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_taxonomy_id}' AND p.post_status != 'trash' LIMIT 1"); |
| 789 | $query = "SELECT COUNT(DISTINCT(p.ID)) |
| 790 | FROM {$post_table} p |
| 791 | JOIN {$term_table} rl ON p.ID = rl.object_id |
| 792 | WHERE rl.term_taxonomy_id = '{$term->term_taxonomy_id}' AND p.post_status != 'trash' LIMIT 1"; |
| 793 | $result = $wpdb->get_var($query); |
| 794 | if (intval($result) > 0) { |
| 795 | $trash_count = intval($result); |
| 796 | } else { |
| 797 | $trash_count = 0; |
| 798 | } |
| 799 | } |
| 800 | } |
| 801 | if ($trash_count === null) { |
| 802 | $trash_count = 0; |
| 803 | } |
| 804 | $terms[$key]->trash_count = $trash_count; |
| 805 | $trash_folders[$term->term_taxonomy_id] = $trash_count; |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | if (!empty($terms) && $initial_trash_folders != $trash_folders) { |
| 810 | delete_transient("premio_folders_without_trash"); |
| 811 | set_transient("premio_folders_without_trash", $trash_folders, 3 * DAY_IN_SECONDS); |
| 812 | } |
| 813 | } |
| 814 | return $terms; |
| 815 | |
| 816 | }//end get_terms_filter_without_trash() |
| 817 | |
| 818 | |
| 819 | /** |
| 820 | * Add Checkbox to page/post lists |
| 821 | * |
| 822 | * @since 1.0.0 |
| 823 | * @access public |
| 824 | * @return $folders |
| 825 | */ |
| 826 | public function custom_bulk_action($bulk_actions) |
| 827 | { |
| 828 | $bulk_actions['move_to_folder'] = __('Move to Folder', 'email_to_eric'); |
| 829 | return $bulk_actions; |
| 830 | |
| 831 | }//end custom_bulk_action() |
| 832 | |
| 833 | |
| 834 | /** |
| 835 | * Folders domain for language translation |
| 836 | * |
| 837 | * @since 1.0.0 |
| 838 | * @access public |
| 839 | * @return $folders |
| 840 | */ |
| 841 | public function folders_text() |
| 842 | { |
| 843 | load_plugin_textdomain("folders", false, dirname(dirname(plugin_basename(__FILE__))).'/languages/'); |
| 844 | |
| 845 | }//end folders_text() |
| 846 | |
| 847 | |
| 848 | /** |
| 849 | * Add custom CSS to footer for media button |
| 850 | * |
| 851 | * @since 1.0.0 |
| 852 | * @access public |
| 853 | * @return $folders |
| 854 | */ |
| 855 | public function admin_footer_for_media() |
| 856 | { |
| 857 | $customize_folders = get_option('customize_folders'); |
| 858 | if (isset($customize_folders['dropdown_color']) && !empty($customize_folders['dropdown_color'])) { |
| 859 | ?> |
| 860 | <style> |
| 861 | #media-attachment-taxonomy-filter, .post-upload-ui .folder_for_media, select.media-select-folder { |
| 862 | border-color: <?php echo esc_attr($customize_folders['dropdown_color']) ?>; |
| 863 | color: <?php echo esc_attr($customize_folders['dropdown_color']) ?> |
| 864 | } |
| 865 | .folder_for_media option { |
| 866 | color:#000000; |
| 867 | } |
| 868 | .folder_for_media option:first-child { |
| 869 | font-weight: bold; |
| 870 | } |
| 871 | </style> |
| 872 | <?php |
| 873 | } |
| 874 | |
| 875 | }//end admin_footer_for_media() |
| 876 | |
| 877 | |
| 878 | /** |
| 879 | * Check for default page/post/media folder on load |
| 880 | * |
| 881 | * @since 1.0.0 |
| 882 | * @access public |
| 883 | * @return $folders |
| 884 | */ |
| 885 | public function check_for_default_folders() |
| 886 | { |
| 887 | global $typenow, $current_screen; |
| 888 | $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0; |
| 889 | $options = get_option('folders_settings'); |
| 890 | $options = (empty($options) || !is_array($options)) ? [] : $options; |
| 891 | $post_status = filter_input(INPUT_GET, 'post_status'); |
| 892 | $last_status = get_option("last_folder_status_for".$typenow); |
| 893 | if (empty($post_status) && !$isAjax && (in_array($typenow, $options) || !empty($last_status)) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) { |
| 894 | $requests = filter_input_array(INPUT_GET); |
| 895 | $requests = empty($requests)||!is_array($requests) ? [] : $requests; |
| 896 | |
| 897 | if ($typenow == "attachment") { |
| 898 | if (count($requests) > 0) { |
| 899 | return; |
| 900 | } |
| 901 | } else if ($typenow == "post") { |
| 902 | if (count($requests) > 0) { |
| 903 | return; |
| 904 | } |
| 905 | } else { |
| 906 | if (count($requests) > 1) { |
| 907 | return; |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | if (!empty($last_status)) { |
| 912 | $status = 1; |
| 913 | if ($last_status != "-1" && $last_status != "all") { |
| 914 | $type = self::get_custom_post_type($typenow); |
| 915 | $term = get_term_by('slug', $last_status, $type); |
| 916 | if (empty($term) || !is_object($term)) { |
| 917 | $status = 0; |
| 918 | } |
| 919 | } |
| 920 | |
| 921 | delete_option("last_folder_status_for".$typenow); |
| 922 | if ($last_status == "all") { |
| 923 | $last_status = ""; |
| 924 | } |
| 925 | |
| 926 | if ($status) { |
| 927 | if ($typenow == "attachment") { |
| 928 | if (!isset($_REQUEST['media_folder'])) { |
| 929 | ?> |
| 930 | <script> |
| 931 | window.location = '<?php echo admin_url("upload.php?post_type=attachment")."&media_folder=".esc_attr($last_status) ?>'; |
| 932 | </script> |
| 933 | <?php |
| 934 | exit; |
| 935 | } |
| 936 | } else { |
| 937 | $post_type = self::get_custom_post_type($typenow); |
| 938 | $admin_url = admin_url("edit.php?post_type=".$typenow); |
| 939 | if (!isset($_REQUEST[$post_type])) { |
| 940 | ?> |
| 941 | <script> |
| 942 | window.location = '<?php echo admin_url("edit.php?post_type=".esc_attr($typenow))."&".esc_attr($post_type)."=".esc_attr($last_status) ?>'; |
| 943 | </script> |
| 944 | <?php |
| 945 | exit; |
| 946 | } |
| 947 | }//end if |
| 948 | }//end if |
| 949 | }//end if |
| 950 | |
| 951 | $default_folders = get_option('default_folders'); |
| 952 | $default_folders = (empty($default_folders) || !is_array($default_folders)) ? [] : $default_folders; |
| 953 | |
| 954 | $status = 1; |
| 955 | if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) { |
| 956 | $type = self::get_custom_post_type($typenow); |
| 957 | if ($default_folders[$typenow] != -1) { |
| 958 | $term = get_term_by('slug', $default_folders[$typenow], $type); |
| 959 | if (empty($term) || !is_object($term)) { |
| 960 | $status = 0; |
| 961 | } |
| 962 | } |
| 963 | } else { |
| 964 | $status = 0; |
| 965 | } |
| 966 | |
| 967 | if ($status) { |
| 968 | if ($typenow == "attachment") { |
| 969 | if (!isset($_REQUEST['media_folder'])) { |
| 970 | if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) { |
| 971 | ?> |
| 972 | <script> |
| 973 | window.location = '<?php echo admin_url("upload.php?post_type=attachment")."&media_folder=".esc_attr($default_folders[$typenow]) ?>'; |
| 974 | </script> |
| 975 | <?php |
| 976 | exit; |
| 977 | } |
| 978 | } |
| 979 | } else { |
| 980 | $search = filter_input(INPUT_GET, "s"); |
| 981 | if (!empty($search)) { |
| 982 | $search = esc_attr($search); |
| 983 | } else { |
| 984 | $search = ""; |
| 985 | } |
| 986 | |
| 987 | $post_type = self::get_custom_post_type($typenow); |
| 988 | if (!isset($_REQUEST[$post_type])) { |
| 989 | if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) { |
| 990 | ?> |
| 991 | <script> |
| 992 | window.location = '<?php echo admin_url("edit.php?post_type=".esc_attr($typenow))."&".esc_attr($post_type)."=".esc_attr($default_folders[$typenow])."&s=".esc_attr($search) ?>'; |
| 993 | </script> |
| 994 | <?php |
| 995 | exit; |
| 996 | } |
| 997 | } |
| 998 | }//end if |
| 999 | }//end if |
| 1000 | }//end if |
| 1001 | |
| 1002 | }//end check_for_default_folders() |
| 1003 | |
| 1004 | |
| 1005 | /** |
| 1006 | * Signup for folders news |
| 1007 | * |
| 1008 | * @since 1.0.0 |
| 1009 | * @access public |
| 1010 | * @return $folders |
| 1011 | */ |
| 1012 | public function folder_update_status() |
| 1013 | { |
| 1014 | $response = []; |
| 1015 | $response['status'] = 0; |
| 1016 | $nonce = filter_input(INPUT_POST, 'nonce'); |
| 1017 | if (!empty($nonce) && wp_verify_nonce($nonce, 'folder_update_status')) { |
| 1018 | $status = filter_input(INPUT_POST, 'status'); |
| 1019 | $email = filter_input(INPUT_POST, 'email'); |
| 1020 | update_option("folder_update_message", 2); |
| 1021 | if ($status == 1) { |
| 1022 | $url = 'https://premioapps.com/premio/signup/email.php'; |
| 1023 | $apiParams = [ |
| 1024 | 'plugin' => 'folders', |
| 1025 | 'email' => $email, |
| 1026 | ]; |
| 1027 | |
| 1028 | // Signup Email for Folders |
| 1029 | $apiResponse = wp_safe_remote_post($url, ['body' => $apiParams, 'timeout' => 15, 'sslverify' => true]); |
| 1030 | |
| 1031 | if (is_wp_error($apiResponse)) { |
| 1032 | wp_safe_remote_post($url, ['body' => $apiParams, 'timeout' => 15, 'sslverify' => false]); |
| 1033 | } |
| 1034 | |
| 1035 | $response['status'] = 1; |
| 1036 | } |
| 1037 | }//end if |
| 1038 | |
| 1039 | echo json_encode($response); |
| 1040 | die; |
| 1041 | |
| 1042 | }//end folder_update_status() |
| 1043 | |
| 1044 | |
| 1045 | /** |
| 1046 | * Add category to media |
| 1047 | * |
| 1048 | * @since 1.0.0 |
| 1049 | * @access public |
| 1050 | * @return $folders |
| 1051 | */ |
| 1052 | public function add_attachment_category($post_ID) |
| 1053 | { |
| 1054 | if (self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) { |
| 1055 | $folder_id = null; |
| 1056 | if (isset($_REQUEST["folder_for_media"])) { |
| 1057 | $folder_id = $this->getRequestVar("folder_for_media"); |
| 1058 | } |
| 1059 | |
| 1060 | if ($folder_id !== null) { |
| 1061 | $folder_id = (int) $folder_id; |
| 1062 | $folder_id = self::sanitize_options($folder_id, "int"); |
| 1063 | if ($folder_id > 0) { |
| 1064 | $post_type = self::get_custom_post_type("attachment"); |
| 1065 | $term = get_term($folder_id); |
| 1066 | if (!empty($term) && isset($term->slug)) { |
| 1067 | wp_set_object_terms($post_ID, $term->slug, $post_type); |
| 1068 | |
| 1069 | $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash"); |
| 1070 | if ($trash_folders === false) { |
| 1071 | $trash_folders = []; |
| 1072 | $initial_trash_folders = []; |
| 1073 | } |
| 1074 | |
| 1075 | if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) { |
| 1076 | unset($trash_folders[$term->term_taxonomy_id]); |
| 1077 | } |
| 1078 | |
| 1079 | if ($initial_trash_folders != $trash_folders) { |
| 1080 | delete_transient("premio_folders_without_trash"); |
| 1081 | set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS)); |
| 1082 | } |
| 1083 | } |
| 1084 | }//end if |
| 1085 | }//end if |
| 1086 | }//end if |
| 1087 | |
| 1088 | }//end add_attachment_category() |
| 1089 | |
| 1090 | |
| 1091 | /** |
| 1092 | * Get Dropdown data for media popup |
| 1093 | * |
| 1094 | * @since 1.0.0 |
| 1095 | * @access public |
| 1096 | * @return $folders |
| 1097 | */ |
| 1098 | public function show_dropdown_on_media_screen() |
| 1099 | { |
| 1100 | if (self::is_for_this_post_type('attachment')) { |
| 1101 | $post_type = self::get_custom_post_type('attachment'); |
| 1102 | global $typenow, $current_screen; |
| 1103 | // Free/Pro Class name change |
| 1104 | if (!class_exists('WCP_Tree')) { |
| 1105 | $files = [ |
| 1106 | 'WCP_Tree' => WCP_DS."includes".WCP_DS."tree.class.php", |
| 1107 | ]; |
| 1108 | |
| 1109 | foreach ($files as $file) { |
| 1110 | if (file_exists(dirname(dirname(__FILE__)).$file)) { |
| 1111 | include_once dirname(dirname(__FILE__)).$file; |
| 1112 | } |
| 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | // Free/Pro Class name change |
| 1117 | $options = WCP_Tree::get_folder_option_data($post_type);?> |
| 1118 | <p class="attachments-category"><?php esc_html_e("Select a folder (Optional)", 'folders'); ?></p> |
| 1119 | <p class="attachments-category"><?php esc_html_e("First select the folder, and then upload the files", 'folders'); ?><br/></p> |
| 1120 | <p> |
| 1121 | <?php |
| 1122 | $request = sanitize_text_field($_SERVER['REQUEST_URI']); |
| 1123 | $request = strpos($request, "post.php"); |
| 1124 | ?> |
| 1125 | <select name="folder_for_media" class="folder_for_media"> |
| 1126 | <option value="-1">- <?php esc_html_e('Unassigned', 'folders'); ?></option> |
| 1127 | <?php echo ($options) ?> |
| 1128 | <?php if (($typenow == "attachment" && isset($current_screen->base) && $current_screen->base == "upload") || ($request !== false) || self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) {?> |
| 1129 | <option value="add-folder"><?php esc_html_e('+ Create a New Folder', 'folders'); ?></option> |
| 1130 | <?php } ?> |
| 1131 | </select> |
| 1132 | </p> |
| 1133 | <?php |
| 1134 | }//end if |
| 1135 | |
| 1136 | }//end show_dropdown_on_media_screen() |
| 1137 | |
| 1138 | |
| 1139 | /** |
| 1140 | * Hide folders |
| 1141 | * |
| 1142 | * @since 1.0.0 |
| 1143 | * @access public |
| 1144 | * @return $folders |
| 1145 | */ |
| 1146 | public function wcp_hide_folders() |
| 1147 | { |
| 1148 | $response = []; |
| 1149 | $response['status'] = 0; |
| 1150 | $response['error'] = 0; |
| 1151 | $response['data'] = []; |
| 1152 | $response['message'] = ""; |
| 1153 | $postData = filter_input_array(INPUT_POST); |
| 1154 | $errorCounter = 0; |
| 1155 | |
| 1156 | if (!isset($postData['status']) || empty($postData['status'])) { |
| 1157 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1158 | $errorCounter++; |
| 1159 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 1160 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1161 | $errorCounter++; |
| 1162 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 1163 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1164 | $errorCounter++; |
| 1165 | } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) { |
| 1166 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 1167 | $errorCounter++; |
| 1168 | } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) { |
| 1169 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 1170 | $errorCounter++; |
| 1171 | } else { |
| 1172 | $type = self::sanitize_options($postData['type']); |
| 1173 | $nonce = self::sanitize_options($postData['nonce']); |
| 1174 | if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) { |
| 1175 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1176 | $errorCounter++; |
| 1177 | } |
| 1178 | }//end if |
| 1179 | |
| 1180 | if ($errorCounter == 0) { |
| 1181 | $type = self::sanitize_options($postData['type']); |
| 1182 | $status = self::sanitize_options($postData['status']); |
| 1183 | $optionName = "wcp_folder_display_status_".$type; |
| 1184 | update_option($optionName, $status); |
| 1185 | $response['status'] = 1; |
| 1186 | } |
| 1187 | |
| 1188 | echo json_encode($response); |
| 1189 | wp_die(); |
| 1190 | |
| 1191 | }//end wcp_hide_folders() |
| 1192 | |
| 1193 | |
| 1194 | /** |
| 1195 | * Change status for folders |
| 1196 | * |
| 1197 | * @since 1.0.0 |
| 1198 | * @access public |
| 1199 | * @return $folders |
| 1200 | */ |
| 1201 | public function wcp_change_folder_display_status() |
| 1202 | { |
| 1203 | $response = []; |
| 1204 | $response['status'] = 0; |
| 1205 | $response['error'] = 0; |
| 1206 | $response['data'] = []; |
| 1207 | $response['message'] = ""; |
| 1208 | $postData = filter_input_array(INPUT_POST); |
| 1209 | $errorCounter = 0; |
| 1210 | if (!isset($postData['status']) || empty($postData['status'])) { |
| 1211 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1212 | $errorCounter++; |
| 1213 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 1214 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1215 | $errorCounter++; |
| 1216 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 1217 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1218 | $errorCounter++; |
| 1219 | } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) { |
| 1220 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 1221 | $errorCounter++; |
| 1222 | } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) { |
| 1223 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 1224 | $errorCounter++; |
| 1225 | } else { |
| 1226 | $type = self::sanitize_options($postData['type']); |
| 1227 | $nonce = self::sanitize_options($postData['nonce']); |
| 1228 | if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) { |
| 1229 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1230 | $errorCounter++; |
| 1231 | } |
| 1232 | }//end if |
| 1233 | |
| 1234 | if ($errorCounter == 0) { |
| 1235 | $type = self::sanitize_options($postData['type']); |
| 1236 | $width = self::sanitize_options($postData['status']); |
| 1237 | $optionName = "wcp_dynamic_display_status_".$type; |
| 1238 | update_option($optionName, $width); |
| 1239 | $response['status'] = 1; |
| 1240 | } |
| 1241 | |
| 1242 | echo json_encode($response); |
| 1243 | wp_die(); |
| 1244 | |
| 1245 | }//end wcp_change_folder_display_status() |
| 1246 | |
| 1247 | |
| 1248 | /** |
| 1249 | * Check for folders for page/post/media id |
| 1250 | * |
| 1251 | * @since 1.0.0 |
| 1252 | * @access public |
| 1253 | * @return $folders |
| 1254 | */ |
| 1255 | public function premio_check_for_other_folders() |
| 1256 | { |
| 1257 | $response = []; |
| 1258 | $response['status'] = 0; |
| 1259 | $response['error'] = 0; |
| 1260 | $response['data'] = []; |
| 1261 | $response['message'] = ""; |
| 1262 | $postData = filter_input_array(INPUT_POST); |
| 1263 | $errorCounter = 0; |
| 1264 | if (!isset($postData['post_id']) || empty($postData['post_id'])) { |
| 1265 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1266 | $errorCounter++; |
| 1267 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 1268 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1269 | $errorCounter++; |
| 1270 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 1271 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1272 | $errorCounter++; |
| 1273 | } else if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['type'])) { |
| 1274 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1275 | $errorCounter++; |
| 1276 | } else if (!current_user_can("manage_categories")) { |
| 1277 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1278 | $errorCounter++; |
| 1279 | } |
| 1280 | |
| 1281 | if ($errorCounter == 0) { |
| 1282 | $folderUndoSettings = []; |
| 1283 | $type = self::sanitize_options($postData['type']); |
| 1284 | $post_id = self::sanitize_options($postData['post_id']); |
| 1285 | |
| 1286 | $post_id = explode(",", $post_id); |
| 1287 | |
| 1288 | $taxonomy = self::get_custom_post_type($type); |
| 1289 | |
| 1290 | foreach ($post_id as $id) { |
| 1291 | $terms = get_the_terms($id, $taxonomy); |
| 1292 | if (!empty($terms) && is_array($terms)) { |
| 1293 | foreach ($terms as $term) { |
| 1294 | if ($term->term_id != $postData['taxonomy']) { |
| 1295 | $response['status'] = -1; |
| 1296 | $response['data']['post_id'] = $postData['post_id']; |
| 1297 | echo json_encode($response); |
| 1298 | wp_die(); |
| 1299 | } |
| 1300 | } |
| 1301 | } |
| 1302 | } |
| 1303 | |
| 1304 | $this->wcp_remove_post_folder(); |
| 1305 | }//end if |
| 1306 | |
| 1307 | echo json_encode($response); |
| 1308 | wp_die(); |
| 1309 | |
| 1310 | }//end premio_check_for_other_folders() |
| 1311 | |
| 1312 | |
| 1313 | /** |
| 1314 | * Remove Folder |
| 1315 | * |
| 1316 | * @since 1.0.0 |
| 1317 | * @access public |
| 1318 | * @return $folders |
| 1319 | */ |
| 1320 | public function wcp_remove_post_folder() |
| 1321 | { |
| 1322 | $response = []; |
| 1323 | $response['status'] = 0; |
| 1324 | $response['error'] = 0; |
| 1325 | $response['data'] = []; |
| 1326 | $response['message'] = ""; |
| 1327 | $postData = filter_input_array(INPUT_POST); |
| 1328 | $errorCounter = 0; |
| 1329 | if (!isset($postData['post_id']) || empty($postData['post_id'])) { |
| 1330 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1331 | $errorCounter++; |
| 1332 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 1333 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1334 | $errorCounter++; |
| 1335 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 1336 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1337 | $errorCounter++; |
| 1338 | } else if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['type'])) { |
| 1339 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1340 | $errorCounter++; |
| 1341 | } else if (!current_user_can("manage_categories")) { |
| 1342 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 1343 | $errorCounter++; |
| 1344 | } |
| 1345 | |
| 1346 | if ($errorCounter == 0) { |
| 1347 | $folderUndoSettings = []; |
| 1348 | $type = self::sanitize_options($postData['type']); |
| 1349 | $post_id = self::sanitize_options($postData['post_id']); |
| 1350 | |
| 1351 | $post_id = explode(",", $post_id); |
| 1352 | |
| 1353 | $taxonomy = self::get_custom_post_type($type); |
| 1354 | |
| 1355 | $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash"); |
| 1356 | if ($trash_folders === false) { |
| 1357 | $trash_folders = []; |
| 1358 | $initial_trash_folders = []; |
| 1359 | } |
| 1360 | |
| 1361 | foreach ($post_id as $id) { |
| 1362 | if (!empty($id) && is_numeric($id) && $id > 0) { |
| 1363 | $terms = get_the_terms($id, $taxonomy); |
| 1364 | $post_terms = [ |
| 1365 | 'post_id' => $id, |
| 1366 | 'terms' => $terms, |
| 1367 | ]; |
| 1368 | if (!empty($terms) && count($terms) > 0) { |
| 1369 | foreach ($terms as $term) { |
| 1370 | if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) { |
| 1371 | unset($trash_folders[$term->term_taxonomy_id]); |
| 1372 | } |
| 1373 | } |
| 1374 | } |
| 1375 | |
| 1376 | $folderUndoSettings[] = $post_terms; |
| 1377 | if (isset($postData['remove_from']) && $postData['remove_from'] == "current" && isset($postData['remove_from']) && $postData['remove_from'] == "current" && isset($postData['active_folder']) && is_numeric($postData['active_folder'])) { |
| 1378 | wp_remove_object_terms($id, intval($postData['active_folder']), $taxonomy); |
| 1379 | } else { |
| 1380 | wp_delete_object_term_relationships($id, $taxonomy); |
| 1381 | } |
| 1382 | }//end if |
| 1383 | }//end foreach |
| 1384 | |
| 1385 | delete_transient("folder_undo_settings"); |
| 1386 | set_transient("folder_undo_settings", $folderUndoSettings, DAY_IN_SECONDS); |
| 1387 | |
| 1388 | if ($initial_trash_folders != $trash_folders) { |
| 1389 | delete_transient("premio_folders_without_trash"); |
| 1390 | set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS)); |
| 1391 | } |
| 1392 | |
| 1393 | $response['status'] = 1; |
| 1394 | }//end if |
| 1395 | |
| 1396 | echo json_encode($response); |
| 1397 | wp_die(); |
| 1398 | |
| 1399 | }//end wcp_remove_post_folder() |
| 1400 | |
| 1401 | |
| 1402 | /** |
| 1403 | * Filter records by selected categories |
| 1404 | * |
| 1405 | * @since 1.0.0 |
| 1406 | * @access public |
| 1407 | * @return $folders |
| 1408 | */ |
| 1409 | public function filter_record_list($query) |
| 1410 | { |
| 1411 | global $typenow; |
| 1412 | |
| 1413 | if ($typenow == "attachment") { |
| 1414 | return; |
| 1415 | } |
| 1416 | |
| 1417 | if (!self::is_for_this_post_type($typenow)) { |
| 1418 | return $query; |
| 1419 | } |
| 1420 | |
| 1421 | $taxonomy = self::get_custom_post_type($typenow); |
| 1422 | |
| 1423 | if (! isset($query->query['post_type'])) { |
| 1424 | return $query; |
| 1425 | } |
| 1426 | |
| 1427 | if (! isset($_REQUEST[$taxonomy])) { |
| 1428 | return $query; |
| 1429 | } |
| 1430 | |
| 1431 | $term = sanitize_text_field($_REQUEST[$taxonomy]); |
| 1432 | if ($term != "-1") { |
| 1433 | return $query; |
| 1434 | } |
| 1435 | |
| 1436 | unset($query->query_vars[$taxonomy]); |
| 1437 | |
| 1438 | $tax_query = [ |
| 1439 | 'taxonomy' => $taxonomy, |
| 1440 | 'operator' => 'NOT EXISTS', |
| 1441 | ]; |
| 1442 | |
| 1443 | $query->set('tax_query', [ $tax_query ]); |
| 1444 | $query->tax_query = new WP_Tax_Query([ $tax_query ]); |
| 1445 | |
| 1446 | return $query; |
| 1447 | |
| 1448 | }//end filter_record_list() |
| 1449 | |
| 1450 | |
| 1451 | /** |
| 1452 | * Get folders list |
| 1453 | * |
| 1454 | * @since 1.0.0 |
| 1455 | * @access public |
| 1456 | * @return $folders |
| 1457 | */ |
| 1458 | public function wcp_get_default_list() |
| 1459 | { |
| 1460 | |
| 1461 | $postData = filter_input_array(INPUT_POST); |
| 1462 | |
| 1463 | $post_type = $postData['type']; |
| 1464 | |
| 1465 | $ttpsts = $this->get_ttlpst($post_type); |
| 1466 | |
| 1467 | $empty_items = self::get_tempt_posts($post_type); |
| 1468 | |
| 1469 | $post_type = self::get_custom_post_type($post_type); |
| 1470 | |
| 1471 | $taxonomies = self::get_terms_hierarchical($post_type); |
| 1472 | |
| 1473 | $response = [ |
| 1474 | 'status' => 1, |
| 1475 | 'total_items' => $ttpsts, |
| 1476 | 'taxonomies' => $taxonomies, |
| 1477 | 'empty_items' => $empty_items, |
| 1478 | ]; |
| 1479 | echo json_encode($response); |
| 1480 | wp_die(); |
| 1481 | |
| 1482 | }//end wcp_get_default_list() |
| 1483 | |
| 1484 | |
| 1485 | /** |
| 1486 | * Get folders list |
| 1487 | * |
| 1488 | * @since 1.0.0 |
| 1489 | * @access public |
| 1490 | * @return $folders |
| 1491 | */ |
| 1492 | function get_folders_default_list() |
| 1493 | { |
| 1494 | $postData = filter_input_array(INPUT_POST); |
| 1495 | |
| 1496 | $post_type = $postData['type']; |
| 1497 | |
| 1498 | $ttpsts = $this->get_ttlpst($post_type); |
| 1499 | |
| 1500 | $empty_items = self::get_tempt_posts($post_type); |
| 1501 | |
| 1502 | $post_type = self::get_custom_post_type($post_type); |
| 1503 | |
| 1504 | $taxonomies = self::get_terms_hierarchical($post_type); |
| 1505 | |
| 1506 | $response = [ |
| 1507 | 'status' => 1, |
| 1508 | 'total_items' => $ttpsts, |
| 1509 | 'empty_items' => $empty_items, |
| 1510 | 'taxonomies' => $taxonomies, |
| 1511 | ]; |
| 1512 | echo json_encode($response); |
| 1513 | die; |
| 1514 | |
| 1515 | }//end get_folders_default_list() |
| 1516 | |
| 1517 | |
| 1518 | /** |
| 1519 | * Save folders data for page/post id |
| 1520 | * |
| 1521 | * @since 1.0.0 |
| 1522 | * @access public |
| 1523 | * @return $folders |
| 1524 | */ |
| 1525 | function save_media_terms($post_id) |
| 1526 | { |
| 1527 | if (wp_is_post_revision($post_id)) { |
| 1528 | return; |
| 1529 | } |
| 1530 | |
| 1531 | $post = get_post($post_id); |
| 1532 | if ($post->post_type !== 'attachment') { |
| 1533 | return; |
| 1534 | } |
| 1535 | |
| 1536 | $post_type = self::get_custom_post_type('attachment'); |
| 1537 | $selected_folder = get_option("selected_".esc_attr($post_type)."_folder"); |
| 1538 | if ($selected_folder != null && !empty($selected_folder)) { |
| 1539 | $terms = get_term($selected_folder); |
| 1540 | if (!empty($terms) && isset($terms->term_id)) { |
| 1541 | wp_set_post_terms($post_id, $terms->term_id, $post_type, false); |
| 1542 | } |
| 1543 | } |
| 1544 | |
| 1545 | }//end save_media_terms() |
| 1546 | |
| 1547 | |
| 1548 | /** |
| 1549 | * Filter attachment data by folder |
| 1550 | * |
| 1551 | * @since 1.0.0 |
| 1552 | * @access public |
| 1553 | * @return $folders |
| 1554 | */ |
| 1555 | public function filter_attachments_grid($args) |
| 1556 | { |
| 1557 | $taxonomy = 'media_folder'; |
| 1558 | if (! isset($args[$taxonomy])) { |
| 1559 | return $args; |
| 1560 | } |
| 1561 | |
| 1562 | $term = sanitize_text_field($args[$taxonomy]); |
| 1563 | if ($term != "-1") { |
| 1564 | return $args; |
| 1565 | } |
| 1566 | |
| 1567 | unset($args[$taxonomy]); |
| 1568 | $args['tax_query'] = [ |
| 1569 | [ |
| 1570 | 'taxonomy' => $taxonomy, |
| 1571 | 'operator' => 'NOT EXISTS', |
| 1572 | ], |
| 1573 | ]; |
| 1574 | $args = apply_filters('media_library_organizer_media_filter_attachments_grid', $args); |
| 1575 | return $args; |
| 1576 | |
| 1577 | }//end filter_attachments_grid() |
| 1578 | |
| 1579 | |
| 1580 | /** |
| 1581 | * Returns total folders |
| 1582 | * |
| 1583 | * @since 1.0.0 |
| 1584 | * @access public |
| 1585 | */ |
| 1586 | public function get_tempt_posts($post_type="") |
| 1587 | { |
| 1588 | global $wpdb; |
| 1589 | |
| 1590 | $post_table = $wpdb->prefix."posts"; |
| 1591 | $term_table = $wpdb->prefix."term_relationships"; |
| 1592 | $term_taxonomy_table = $wpdb->prefix."term_taxonomy"; |
| 1593 | $term_meta = $wpdb->prefix."termmeta"; |
| 1594 | $taxonomy = self::get_custom_post_type($post_type); |
| 1595 | $tlrcds = null; |
| 1596 | if(has_filter("premio_folder_un_categorized_items")) { |
| 1597 | $tlrcds = apply_filters("premio_folder_un_categorized_items", $post_type, $taxonomy); |
| 1598 | } |
| 1599 | if($tlrcds === null) { |
| 1600 | $user_filter = false; |
| 1601 | |
| 1602 | if(!$user_filter) { |
| 1603 | if ($post_type != "attachment") { |
| 1604 | $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND ( |
| 1605 | NOT EXISTS ( |
| 1606 | SELECT 1 |
| 1607 | FROM {$term_table} |
| 1608 | INNER JOIN {$term_taxonomy_table} |
| 1609 | ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id |
| 1610 | WHERE {$term_taxonomy_table}.taxonomy = '%s' |
| 1611 | AND {$term_table}.object_id = {$post_table}.ID |
| 1612 | ) |
| 1613 | ) 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' OR {$post_table}.post_status = 'pending'))"; |
| 1614 | } else { |
| 1615 | $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND ( |
| 1616 | NOT EXISTS ( |
| 1617 | SELECT 1 |
| 1618 | FROM {$term_table} |
| 1619 | INNER JOIN {$term_taxonomy_table} |
| 1620 | ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id |
| 1621 | WHERE {$term_taxonomy_table}.taxonomy = '%s' |
| 1622 | AND {$term_table}.object_id = {$post_table}.ID |
| 1623 | ) |
| 1624 | ) AND {$post_table}.post_type = '%s' AND {$post_table}.post_status = 'inherit'"; |
| 1625 | } |
| 1626 | } else { |
| 1627 | if ($post_type != "attachment") { |
| 1628 | $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND ( |
| 1629 | NOT EXISTS ( |
| 1630 | SELECT 1 |
| 1631 | FROM {$term_table} |
| 1632 | INNER JOIN {$term_taxonomy_table} |
| 1633 | ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id |
| 1634 | INNER JOIN {$term_meta} |
| 1635 | ON {$term_meta}.term_id = {$term_table}.term_taxonomy_id AND {$term_meta}.meta_key = 'created_by' AND {$term_meta}.meta_value = {$user_id} |
| 1636 | WHERE {$term_taxonomy_table}.taxonomy = '%s' |
| 1637 | AND {$term_table}.object_id = {$post_table}.ID |
| 1638 | ) |
| 1639 | ) 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' OR {$post_table}.post_status = 'pending'))"; |
| 1640 | } else { |
| 1641 | $query = "SELECT COUNT(DISTINCT({$post_table}.ID)) AS total_records FROM {$post_table} WHERE 1=1 AND ( |
| 1642 | NOT EXISTS ( |
| 1643 | SELECT 1 |
| 1644 | FROM {$term_table} |
| 1645 | INNER JOIN {$term_taxonomy_table} |
| 1646 | ON {$term_taxonomy_table}.term_taxonomy_id = {$term_table}.term_taxonomy_id |
| 1647 | INNER JOIN {$term_meta} |
| 1648 | ON {$term_meta}.term_id = {$term_table}.term_taxonomy_id AND {$term_meta}.meta_key = 'created_by' AND {$term_meta}.meta_value = {$user_id} |
| 1649 | WHERE {$term_taxonomy_table}.taxonomy = '%s' |
| 1650 | AND {$term_table}.object_id = {$post_table}.ID |
| 1651 | ) |
| 1652 | ) AND {$post_table}.post_type = '%s' AND {$post_table}.post_status = 'inherit'"; |
| 1653 | } |
| 1654 | } |
| 1655 | |
| 1656 | $query = $wpdb->prepare($query, $taxonomy, $post_type); |
| 1657 | |
| 1658 | $tlrcds = $wpdb->get_var($query); |
| 1659 | } |
| 1660 | |
| 1661 | if(!empty($tlrcds)) { |
| 1662 | return $tlrcds; |
| 1663 | } else { |
| 1664 | return 0; |
| 1665 | } |
| 1666 | |
| 1667 | }//end get_tempt_posts() |
| 1668 | |
| 1669 | |
| 1670 | /** |
| 1671 | * Filter input data |
| 1672 | * |
| 1673 | * @since 1.0.0 |
| 1674 | * @access public |
| 1675 | * @return $folders |
| 1676 | */ |
| 1677 | public function getRequestVar($var) |
| 1678 | { |
| 1679 | $response = filter_input(INPUT_POST, $var); |
| 1680 | if (empty($response)) { |
| 1681 | $response = filter_input(INPUT_GET, $var); |
| 1682 | } |
| 1683 | |
| 1684 | return $response; |
| 1685 | |
| 1686 | }//end getRequestVar() |
| 1687 | |
| 1688 | |
| 1689 | /** |
| 1690 | * Redirect to default folder |
| 1691 | * |
| 1692 | * @since 1.0.0 |
| 1693 | * @access public |
| 1694 | * @return $folders |
| 1695 | */ |
| 1696 | public function output_backbone_view_filters() |
| 1697 | { |
| 1698 | |
| 1699 | global $typenow, $current_screen; |
| 1700 | $isAjax = (defined('DOING_AJAX') && DOING_AJAX) ? 1 : 0; |
| 1701 | $options = get_option('folders_settings'); |
| 1702 | $options = (empty($options) || !is_array($options)) ? [] : $options; |
| 1703 | $last_status = get_option("last_folder_status_for".$typenow); |
| 1704 | if (!$isAjax && (in_array($typenow, $options) || !empty($last_status)) && (isset($current_screen->base) && ($current_screen->base == "edit" || ($current_screen->base == "upload")))) { |
| 1705 | $default_folders = get_option('default_folders'); |
| 1706 | $default_folders = (empty($default_folders) || !is_array($default_folders)) ? [] : $default_folders; |
| 1707 | |
| 1708 | if (!empty($last_status)) { |
| 1709 | $status = 1; |
| 1710 | if ($last_status != "-1" && $last_status != "all") { |
| 1711 | $type = self::get_custom_post_type($typenow); |
| 1712 | $term = get_term_by('slug', $last_status, $type); |
| 1713 | if (empty($term) || !is_object($term)) { |
| 1714 | $status = 0; |
| 1715 | } |
| 1716 | } |
| 1717 | |
| 1718 | delete_option("last_folder_status_for".$typenow); |
| 1719 | if ($last_status == "all") { |
| 1720 | $last_status = ""; |
| 1721 | } |
| 1722 | |
| 1723 | if ($status) { |
| 1724 | if ($typenow == "attachment") { |
| 1725 | if (!isset($_REQUEST['media_folder'])) { |
| 1726 | ?> |
| 1727 | <script> |
| 1728 | window.location = '<?php echo admin_url("upload.php?post_type=attachment")."&media_folder=".esc_attr($last_status) ?>'; |
| 1729 | </script> |
| 1730 | <?php |
| 1731 | exit; |
| 1732 | } |
| 1733 | } |
| 1734 | } |
| 1735 | }//end if |
| 1736 | |
| 1737 | $status = 1; |
| 1738 | if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) { |
| 1739 | $type = self::get_custom_post_type($typenow); |
| 1740 | if ($default_folders[$typenow] != -1) { |
| 1741 | $term = get_term_by('slug', $default_folders[$typenow], $type); |
| 1742 | if (empty($term) || !is_object($term)) { |
| 1743 | $status = 0; |
| 1744 | } |
| 1745 | } |
| 1746 | } else { |
| 1747 | $status = 0; |
| 1748 | } |
| 1749 | |
| 1750 | if ($status) { |
| 1751 | if ($typenow == "attachment") { |
| 1752 | if (!isset($_REQUEST['media_folder'])) { |
| 1753 | if (isset($default_folders[$typenow]) && !empty($default_folders[$typenow])) { |
| 1754 | ?> |
| 1755 | <script> |
| 1756 | window.location = '<?php echo admin_url("upload.php?post_type=attachment")."&media_folder=".esc_attr($default_folders[$typenow]) ?>'; |
| 1757 | </script> |
| 1758 | <?php |
| 1759 | exit; |
| 1760 | } |
| 1761 | } |
| 1762 | } |
| 1763 | } |
| 1764 | }//end if |
| 1765 | |
| 1766 | if (!(self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media'))) { |
| 1767 | return; |
| 1768 | } |
| 1769 | |
| 1770 | if ($typenow == "attachment") { |
| 1771 | // Free/Pro URL Change |
| 1772 | global $typenow; |
| 1773 | $is_active = 1; |
| 1774 | $folders = -1; |
| 1775 | |
| 1776 | $hasStars = self::check_for_setting("has_stars", "general"); |
| 1777 | $hasChild = self::check_for_setting("has_child", "general"); |
| 1778 | $hasChild = empty($hasChild) ? 0 : 1; |
| 1779 | $hasStars = empty($hasStars) ? 0 : 1; |
| 1780 | // Free/Pro URL Change |
| 1781 | wp_enqueue_script('folders-media', WCP_FOLDER_URL.'assets/js/media.js', [ 'media-editor', 'media-views' ], WCP_FOLDER_VERSION, true); |
| 1782 | wp_localize_script( |
| 1783 | 'folders-media', |
| 1784 | 'folders_media_options', |
| 1785 | [ |
| 1786 | 'terms' => self::get_terms_hierarchical('media_folder'), |
| 1787 | 'taxonomy' => get_taxonomy('media_folder'), |
| 1788 | 'ajax_url' => admin_url("admin-ajax.php"), |
| 1789 | 'activate_url' => $this->getFoldersUpgradeURL(), |
| 1790 | 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'), |
| 1791 | 'is_key_active' => $is_active, |
| 1792 | 'hasStars' => $hasStars, |
| 1793 | 'hasChildren' => $hasChild, |
| 1794 | ] |
| 1795 | ); |
| 1796 | // Free/Pro URL Change |
| 1797 | wp_enqueue_style('folders-media', WCP_FOLDER_URL.'assets/css/media.css', [], WCP_FOLDER_VERSION); |
| 1798 | } else if (!self::is_active_for_screen() && self::is_for_this_post_type('attachment')) { |
| 1799 | // Free/Pro URL Change |
| 1800 | global $typenow; |
| 1801 | global $current_screen; |
| 1802 | // echo "<pre>"; print_r($current_screen); die; |
| 1803 | if (!isset($current_screen->base) || $current_screen->base != "plugins") { |
| 1804 | $is_active = 1; |
| 1805 | $folders = -1; |
| 1806 | |
| 1807 | remove_filter("terms_clauses", "TO_apply_order_filter"); |
| 1808 | |
| 1809 | // Free/Pro URL Change |
| 1810 | $is_rtl = 0; |
| 1811 | if (function_exists('is_rtl') && is_rtl()) { |
| 1812 | $is_rtl = 1; |
| 1813 | } |
| 1814 | |
| 1815 | $can_manage_folder = current_user_can("manage_categories") ? 1 : 0; |
| 1816 | $width = 275; |
| 1817 | $taxonomy_status = 0; |
| 1818 | $selected_taxonomy = ""; |
| 1819 | $show_in_page = false; |
| 1820 | $admin_url = admin_url("upload.php?post_type=attachment&media_folder="); |
| 1821 | |
| 1822 | $taxonomies = self::get_terms_hierarchical('media_folder'); |
| 1823 | |
| 1824 | $folder_settings = []; |
| 1825 | foreach ($taxonomies as $taxonomy) { |
| 1826 | $is_sticky = get_term_meta($taxonomy->term_id, "is_folder_sticky", true); |
| 1827 | $is_high = get_term_meta($taxonomy->term_id, "is_highlighted", true); |
| 1828 | $folder_settings[] = [ |
| 1829 | 'folder_id' => $taxonomy->term_id, |
| 1830 | 'is_sticky' => intval($is_sticky), |
| 1831 | 'is_high' => intval($is_high), |
| 1832 | 'nonce' => wp_create_nonce('wcp_folder_term_'.$taxonomy->term_id), |
| 1833 | 'is_deleted' => 0, |
| 1834 | 'slug' => $taxonomy->slug, |
| 1835 | 'folder_count' => intval($taxonomy->trash_count), |
| 1836 | ]; |
| 1837 | } |
| 1838 | |
| 1839 | $hasStars = self::check_for_setting("has_stars", "general"); |
| 1840 | $hasChild = self::check_for_setting("has_child", "general"); |
| 1841 | $hasChild = empty($hasChild) ? 0 : 1; |
| 1842 | $hasStars = empty($hasStars) ? 0 : 1; |
| 1843 | |
| 1844 | $customize_folders = get_option('customize_folders'); |
| 1845 | $use_folder_undo = !isset($customize_folders['use_folder_undo']) ? "yes" : $customize_folders['use_folder_undo']; |
| 1846 | $defaultTimeout = !isset($customize_folders['default_timeout']) ? 5 : intval($customize_folders['default_timeout']); |
| 1847 | if (empty($defaultTimeout) || !is_numeric($defaultTimeout) || $defaultTimeout < 0) { |
| 1848 | $defaultTimeout = 5; |
| 1849 | } |
| 1850 | |
| 1851 | $defaultTimeout = ($defaultTimeout * 1000); |
| 1852 | |
| 1853 | $default_folders = get_option("default_folders"); |
| 1854 | $default_folder = ""; |
| 1855 | if (isset($default_folders["attachment"])) { |
| 1856 | $default_folder = $default_folders["attachment"]; |
| 1857 | } |
| 1858 | |
| 1859 | $use_shortcuts = !isset($customize_folders['use_shortcuts']) ? "yes" : $customize_folders['use_shortcuts']; |
| 1860 | |
| 1861 | $lang = $this->js_strings(); |
| 1862 | wp_dequeue_script("jquery-jstree"); |
| 1863 | // CMS Tree Page View Conflict |
| 1864 | wp_enqueue_script('folders-overlayscrollbars', WCP_FOLDER_URL.'assets/js/jquery.overlayscrollbars.min.js', [], WCP_FOLDER_VERSION); |
| 1865 | wp_enqueue_script('folders-tree', WCP_FOLDER_URL.'assets/js/jstree.min.js', [], WCP_FOLDER_VERSION); |
| 1866 | wp_enqueue_script('wcp-folders-media', WCP_FOLDER_URL.'assets/js/page-post-media.min.js', ['jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'], WCP_FOLDER_VERSION, true); |
| 1867 | wp_enqueue_script('wcp-jquery-touch', plugin_dir_url(dirname(__FILE__)).'assets/js/jquery.ui.touch-punch.min.js', ['jquery'], WCP_FOLDER_VERSION); |
| 1868 | wp_localize_script( |
| 1869 | 'wcp-folders-media', |
| 1870 | 'folders_media_options', |
| 1871 | [ |
| 1872 | 'terms' => $taxonomies, |
| 1873 | 'taxonomy' => get_taxonomy('media_folder'), |
| 1874 | 'ajax_url' => admin_url("admin-ajax.php"), |
| 1875 | 'media_page_url' => admin_url("upload.php?media_folder="), |
| 1876 | 'activate_url' => $this->getFoldersUpgradeURL(), |
| 1877 | 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'), |
| 1878 | 'is_key_active' => $is_active, |
| 1879 | 'folders' => $folders, |
| 1880 | 'upgrade_url' => $this->getFoldersUpgradeURL(), |
| 1881 | 'post_type' => 'attachment', |
| 1882 | 'page_url' => $admin_url, |
| 1883 | 'current_url' => "", |
| 1884 | 'ajax_image' => plugin_dir_url(dirname(__FILE__))."assets/images/ajax-loader.gif", |
| 1885 | 'register_url' => "", |
| 1886 | 'isRTL' => $is_rtl, |
| 1887 | 'can_manage_folder' => $can_manage_folder, |
| 1888 | 'folder_width' => $width, |
| 1889 | 'taxonomy_status' => $taxonomy_status, |
| 1890 | 'selected_taxonomy' => $selected_taxonomy, |
| 1891 | 'show_in_page' => $show_in_page, |
| 1892 | 'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png', |
| 1893 | 'folder_settings' => $folder_settings, |
| 1894 | 'hasStars' => $hasStars, |
| 1895 | 'hasChildren' => $hasChild, |
| 1896 | 'useFolderUndo' => $use_folder_undo, |
| 1897 | 'defaultTimeout' => $defaultTimeout, |
| 1898 | 'default_folder' => $default_folder, |
| 1899 | 'use_shortcuts' => $use_shortcuts, |
| 1900 | 'lang' => $lang |
| 1901 | ] |
| 1902 | ); |
| 1903 | // Free/Pro URL Change |
| 1904 | wp_enqueue_style('folders-jstree', WCP_FOLDER_URL.'assets/css/jstree.min.css', [], WCP_FOLDER_VERSION); |
| 1905 | wp_enqueue_style('folder-overlayscrollbars', WCP_FOLDER_URL.'assets/css/overlayscrollbars.min.css', [], WCP_FOLDER_VERSION); |
| 1906 | wp_enqueue_style('folder-folders', WCP_FOLDER_URL.'assets/css/folders.min.css', [], WCP_FOLDER_VERSION); |
| 1907 | wp_enqueue_style('folders-media', WCP_FOLDER_URL.'assets/css/page-post-media.min.css', [], WCP_FOLDER_VERSION); |
| 1908 | wp_enqueue_style('folder-icon', WCP_FOLDER_URL.'assets/css/folder-icon.css', [], WCP_FOLDER_VERSION); |
| 1909 | $width = 275; |
| 1910 | $string = ""; |
| 1911 | $css_text = ""; |
| 1912 | $customize_folders = get_option('customize_folders'); |
| 1913 | if (!isset($customize_folders['new_folder_color']) || empty($customize_folders['new_folder_color'])) { |
| 1914 | $customize_folders['new_folder_color'] = "#FA166B"; |
| 1915 | } |
| 1916 | |
| 1917 | $css_text .= ".media-frame a.add-new-folder { background-color: ".esc_attr($customize_folders['new_folder_color'])."; border-color: ".esc_attr($customize_folders['new_folder_color'])."}"; |
| 1918 | $css_text .= ".wcp-hide-show-buttons .toggle-buttons { background-color: ".esc_attr($customize_folders['new_folder_color'])."; }"; |
| 1919 | $css_text .= ".folders-toggle-button span { background-color: ".esc_attr($customize_folders['new_folder_color'])."; }"; |
| 1920 | $css_text .= ".ui-resizable-handle.ui-resizable-e:before, .ui-resizable-handle.ui-resizable-w:before {border-color: ".esc_attr($customize_folders['new_folder_color'])." !important}"; |
| 1921 | |
| 1922 | if (!isset($customize_folders['folder_bg_color']) || empty($customize_folders['folder_bg_color'])) { |
| 1923 | $customize_folders['folder_bg_color'] = "#FA166B"; |
| 1924 | } |
| 1925 | |
| 1926 | $rgbColor = self::hexToRgb($customize_folders['folder_bg_color']); |
| 1927 | $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked), body:not(.no-hover-css) #custom-scroll-menu .jstree-hovered:not(.jstree-clicked):hover { background: rgba(".esc_attr($rgbColor['r']).",".esc_attr($rgbColor['g']).",".esc_attr($rgbColor['b']).", 0.08) !important; color: #333333;}"; |
| 1928 | $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked, body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked:not(.jstree-clicked):focus, #custom-scroll-menu .jstree-clicked, #custom-scroll-menu .jstree-clicked:hover { background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff !important; }"; |
| 1929 | $css_text .= "body:not(.no-hover-css) #custom-scroll-menu .jstree-clicked .folder-actions { background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff !important; }"; |
| 1930 | $css_text .= "#custom-scroll-menu .jstree-hovered.wcp-drop-hover, #custom-scroll-menu .jstree-hovered.wcp-drop-hover:hover, #custom-scroll-menu .jstree-clicked.wcp-drop-hover, #custom-scroll-menu .jstree-clicked.wcp-drop-hover:hover, body #custom-scroll-menu *.drag-in >, body #custom-scroll-menu *.drag-in > a:hover { background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff !important; }"; |
| 1931 | $css_text .= ".drag-bot > a { border-bottom: solid 2px ".esc_attr($customize_folders['folder_bg_color'])."}"; |
| 1932 | $css_text .= ".drag-up > a { border-top: solid 2px ".esc_attr($customize_folders['folder_bg_color'])."}"; |
| 1933 | $css_text .= "body:not(.no-hover-css) #custom-scroll-menu *.drag-in > a.jstree-hovered, body:not(.no-hover-css) #custom-scroll-menu *.drag-in > a.jstree-hovered:hover {background: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #fff !important;}"; |
| 1934 | $css_text .= ".orange-bg > span, .jstree-clicked, .header-posts a.active-item, .un-categorised-items.active-item, .sticky-folders ul li a.active-item { background-color: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff !important; }"; |
| 1935 | $css_text .= "body:not(.no-hover-css) .wcp-container .route .title:hover, body:not(.no-hover-css) .header-posts a:hover, body:not(.no-hover-css) .un-categorised-items:hover, body:not(.no-hover-css) .sticky-folders ul li a:hover { background: rgba(".esc_attr($rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08")."); color: #333333;}"; |
| 1936 | $css_text .= ".wcp-drop-hover {background-color: ".esc_attr($customize_folders['folder_bg_color'])." !important; color: #ffffff; }"; |
| 1937 | $css_text .= "#custom-menu .route .nav-icon .wcp-icon {color: ".esc_attr($customize_folders['folder_bg_color'])." !important;}"; |
| 1938 | $css_text .= ".mCS-3d.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar {background-color: ".esc_attr($customize_folders['folder_bg_color'])." !important;}"; |
| 1939 | $css_text .= ".os-theme-dark>.os-scrollbar>.os-scrollbar-track>.os-scrollbar-handle {background-color: ".esc_attr($customize_folders['folder_bg_color'])." !important;}"; |
| 1940 | $css_text .= "body:not(.no-hover-css) .jstree-hovered {background: rgba(".esc_attr($rgbColor['r'].",".$rgbColor['g'].",".$rgbColor['b'].", 0.08").") }"; |
| 1941 | $css_text .= ".jstree-default .jstree-clicked { background-color:".esc_attr($customize_folders['folder_bg_color'])."}"; |
| 1942 | $css_text .= ".jstree-node.drag-in > a.jstree-anchor.jstree-hovered { background-color: ".esc_attr($customize_folders['folder_bg_color'])."; color: #ffffff; }"; |
| 1943 | $css_text .= "#custom-scroll-menu .jstree-hovered:not(.jstree-clicked) .pfolder-folder-close { color: ".esc_attr($customize_folders['folder_bg_color'])."; }"; |
| 1944 | |
| 1945 | if (!isset($customize_folders['bulk_organize_button_color']) || empty($customize_folders['bulk_organize_button_color'])) { |
| 1946 | $customize_folders['bulk_organize_button_color'] = "#FA166B"; |
| 1947 | } |
| 1948 | |
| 1949 | $css_text .= "button.button.organize-button { background-color: ".esc_attr($customize_folders['bulk_organize_button_color'])."; border-color: ".esc_attr($customize_folders['bulk_organize_button_color'])."; }"; |
| 1950 | $css_text .= "button.button.organize-button:hover { background-color: ".esc_attr($customize_folders['bulk_organize_button_color'])."; border-color: ".esc_attr($customize_folders['bulk_organize_button_color'])."; }"; |
| 1951 | |
| 1952 | $font_family = ""; |
| 1953 | if (isset($customize_folders['folder_font']) && !empty($customize_folders['folder_font'])) { |
| 1954 | $folder_fonts = self::get_font_list(); |
| 1955 | $font_family = $customize_folders['folder_font']; |
| 1956 | if (isset($folder_fonts[$font_family])) { |
| 1957 | $css_text .= ".wcp-container, .folder-popup-form { font-family: ".esc_attr($font_family)." !important; }"; |
| 1958 | } |
| 1959 | |
| 1960 | if ($folder_fonts[$font_family] == "Default") { |
| 1961 | $font_family = ""; |
| 1962 | } |
| 1963 | } |
| 1964 | |
| 1965 | if (isset($customize_folders['folder_size']) && !empty($customize_folders['folder_size'])) { |
| 1966 | $css_text .= ".wcp-container .route span.title-text, .header-posts a, .un-categorised-items a, .sticky-title { font-size: ".esc_attr($customize_folders['folder_size'])."px; }"; |
| 1967 | } |
| 1968 | |
| 1969 | if (!empty($font_family)) { |
| 1970 | wp_enqueue_style('custom-google-fonts', 'https://fonts.googleapis.com/css?family='.urlencode($font_family), false); |
| 1971 | } |
| 1972 | |
| 1973 | wp_add_inline_style('folders-media', $css_text); |
| 1974 | }//end if |
| 1975 | }//end if |
| 1976 | |
| 1977 | }//end output_backbone_view_filters() |
| 1978 | |
| 1979 | |
| 1980 | /** |
| 1981 | * Get folders by hierarchy |
| 1982 | * |
| 1983 | * @since 1.0.0 |
| 1984 | * @access public |
| 1985 | * @return $folders |
| 1986 | */ |
| 1987 | public function get_terms_hierarchical($taxonomy) |
| 1988 | { |
| 1989 | $terms = get_terms( |
| 1990 | [ |
| 1991 | 'taxonomy' => $taxonomy, |
| 1992 | 'hide_empty' => false, |
| 1993 | 'parent' => 0, |
| 1994 | 'orderby' => 'meta_value_num', |
| 1995 | 'order' => 'ASC', |
| 1996 | 'hierarchical' => false, |
| 1997 | 'update_count_callback' => '_update_generic_term_count', |
| 1998 | 'meta_query' => [ |
| 1999 | [ |
| 2000 | 'key' => 'wcp_custom_order', |
| 2001 | 'type' => 'NUMERIC', |
| 2002 | ], |
| 2003 | ], |
| 2004 | ] |
| 2005 | ); |
| 2006 | $hierarchical_terms = []; |
| 2007 | if (!empty($terms)) { |
| 2008 | foreach ($terms as $term) { |
| 2009 | if (!empty($term) && isset($term->term_id)) { |
| 2010 | $term->term_name = $term->name; |
| 2011 | $hierarchical_terms[] = $term; |
| 2012 | $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, "-"); |
| 2013 | } |
| 2014 | } |
| 2015 | } |
| 2016 | |
| 2017 | return $hierarchical_terms; |
| 2018 | |
| 2019 | }//end get_terms_hierarchical() |
| 2020 | |
| 2021 | |
| 2022 | /** |
| 2023 | * Get Child folders |
| 2024 | * |
| 2025 | * @since 1.0.0 |
| 2026 | * @access public |
| 2027 | * @return $folders |
| 2028 | */ |
| 2029 | public static function get_child_terms($taxonomy, $hierarchical_terms, $term_id, $separator="-") |
| 2030 | { |
| 2031 | $terms = get_terms( |
| 2032 | [ |
| 2033 | 'taxonomy' => $taxonomy, |
| 2034 | 'hide_empty' => false, |
| 2035 | 'parent' => $term_id, |
| 2036 | 'orderby' => 'meta_value_num', |
| 2037 | 'order' => 'ASC', |
| 2038 | 'hierarchical' => false, |
| 2039 | 'update_count_callback' => '_update_generic_term_count', |
| 2040 | 'meta_query' => [ |
| 2041 | [ |
| 2042 | 'key' => 'wcp_custom_order', |
| 2043 | 'type' => 'NUMERIC', |
| 2044 | ], |
| 2045 | ], |
| 2046 | ] |
| 2047 | ); |
| 2048 | if (!empty($terms)) { |
| 2049 | foreach ($terms as $term) { |
| 2050 | if (isset($term->name)) { |
| 2051 | $term->name = $separator." ".$term->name; |
| 2052 | $term->term_name = trim($term->name, "-"); |
| 2053 | $hierarchical_terms[] = $term; |
| 2054 | $hierarchical_terms = self::get_child_terms($taxonomy, $hierarchical_terms, $term->term_id, $separator."-"); |
| 2055 | } |
| 2056 | } |
| 2057 | } |
| 2058 | |
| 2059 | return $hierarchical_terms; |
| 2060 | |
| 2061 | }//end get_child_terms() |
| 2062 | |
| 2063 | |
| 2064 | /** |
| 2065 | * Update folders data for page, post, media |
| 2066 | * |
| 2067 | * @since 1.0.0 |
| 2068 | * @access public |
| 2069 | * @return $folders |
| 2070 | */ |
| 2071 | public function update_folder_new_term_relationships($object_id="", $term_ids=[], $taxonomy="") |
| 2072 | { |
| 2073 | if (is_array($term_ids) && !empty($term_ids)) { |
| 2074 | $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash"); |
| 2075 | if ($trash_folders === false) { |
| 2076 | $trash_folders = []; |
| 2077 | $initial_trash_folders = []; |
| 2078 | } |
| 2079 | |
| 2080 | foreach ($term_ids as $term_id) { |
| 2081 | $term = get_term($term_id, $taxonomy); |
| 2082 | if (isset($term->term_taxonomy_id) && isset($trash_folders[$term->term_taxonomy_id])) { |
| 2083 | unset($trash_folders[$term->term_taxonomy_id]); |
| 2084 | } |
| 2085 | } |
| 2086 | |
| 2087 | if ($initial_trash_folders != $trash_folders) { |
| 2088 | delete_transient("premio_folders_without_trash"); |
| 2089 | set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS)); |
| 2090 | } |
| 2091 | } |
| 2092 | |
| 2093 | }//end update_folder_new_term_relationships() |
| 2094 | |
| 2095 | |
| 2096 | /** |
| 2097 | * Update folders data for page, post, media |
| 2098 | * |
| 2099 | * @since 1.0.0 |
| 2100 | * @access public |
| 2101 | * @return $folders |
| 2102 | */ |
| 2103 | public function update_folder_term_relationships($object_id="", $term_ids=[], $taxonomy="") |
| 2104 | { |
| 2105 | if (is_array($term_ids) && !empty($term_ids)) { |
| 2106 | $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash"); |
| 2107 | if ($trash_folders === false) { |
| 2108 | $trash_folders = []; |
| 2109 | $initial_trash_folders = []; |
| 2110 | } |
| 2111 | |
| 2112 | foreach ($term_ids as $term_id) { |
| 2113 | $term = get_term($term_id, $taxonomy); |
| 2114 | if (isset($term->term_taxonomy_id) && isset($trash_folders[$term_id])) { |
| 2115 | unset($trash_folders[$term->term_taxonomy_id]); |
| 2116 | } |
| 2117 | } |
| 2118 | |
| 2119 | if ($initial_trash_folders != $trash_folders) { |
| 2120 | delete_transient("premio_folders_without_trash"); |
| 2121 | set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS)); |
| 2122 | } |
| 2123 | } |
| 2124 | |
| 2125 | }//end update_folder_term_relationships() |
| 2126 | |
| 2127 | |
| 2128 | /** |
| 2129 | * Get child folders |
| 2130 | * |
| 2131 | * @since 1.0.0 |
| 2132 | * @access public |
| 2133 | * @return $folders |
| 2134 | */ |
| 2135 | private function add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $current_term_id, $current_depth) |
| 2136 | { |
| 2137 | |
| 2138 | if (! isset($hierarchy[$current_term_id])) { |
| 2139 | return $hierarchical_terms; |
| 2140 | } |
| 2141 | |
| 2142 | foreach ($hierarchy[$current_term_id] as $child_term_id) { |
| 2143 | $child_term = get_term($child_term_id, $taxonomy); |
| 2144 | |
| 2145 | $child_term->name = str_pad('', $current_depth, '-', STR_PAD_LEFT).' '.$child_term->name; |
| 2146 | |
| 2147 | $hierarchical_terms[] = $child_term; |
| 2148 | |
| 2149 | $hierarchical_terms = self::add_child_terms_recursive($taxonomy, $hierarchical_terms, $hierarchy, $child_term_id, ( $current_depth + 1 )); |
| 2150 | } |
| 2151 | |
| 2152 | return $hierarchical_terms; |
| 2153 | |
| 2154 | }//end add_child_terms_recursive() |
| 2155 | |
| 2156 | |
| 2157 | /** |
| 2158 | * Filter data for attachments |
| 2159 | * |
| 2160 | * @since 1.0.0 |
| 2161 | * @access public |
| 2162 | * @return $folders |
| 2163 | */ |
| 2164 | public function filter_attachments_list($query) |
| 2165 | { |
| 2166 | |
| 2167 | if (! isset($query->query['post_type'])) { |
| 2168 | return $query; |
| 2169 | } |
| 2170 | |
| 2171 | if (is_array($query->query['post_type']) && ! in_array('attachment', $query->query['post_type'])) { |
| 2172 | return $query; |
| 2173 | } |
| 2174 | |
| 2175 | if (! is_array($query->query['post_type']) && strpos($query->query['post_type'], 'attachment') === false) { |
| 2176 | return $query; |
| 2177 | } |
| 2178 | |
| 2179 | if (! isset($_REQUEST['media_folder'])) { |
| 2180 | return $query; |
| 2181 | } |
| 2182 | |
| 2183 | $term = sanitize_text_field(wp_unslash($_REQUEST['media_folder'])); |
| 2184 | if ($term != "-1") { |
| 2185 | return $query; |
| 2186 | } |
| 2187 | |
| 2188 | unset($query->query_vars['media_folder']); |
| 2189 | |
| 2190 | $tax_query = [ |
| 2191 | 'taxonomy' => 'media_folder', |
| 2192 | 'operator' => 'NOT EXISTS', |
| 2193 | ]; |
| 2194 | |
| 2195 | $query->set('tax_query', [ $tax_query ]); |
| 2196 | $query->tax_query = new WP_Tax_Query([ $tax_query ]); |
| 2197 | |
| 2198 | $query = apply_filters('media_library_organizer_media_filter_attachments', $query, $_REQUEST); |
| 2199 | |
| 2200 | return $query; |
| 2201 | |
| 2202 | }//end filter_attachments_list() |
| 2203 | |
| 2204 | |
| 2205 | /** |
| 2206 | * Filter data for attachments |
| 2207 | * |
| 2208 | * @since 1.0.0 |
| 2209 | * @access public |
| 2210 | * @return $folders |
| 2211 | */ |
| 2212 | public function output_list_table_filters($post_type, $view_name) |
| 2213 | { |
| 2214 | if ($post_type != 'attachment') { |
| 2215 | return; |
| 2216 | } |
| 2217 | |
| 2218 | if ($view_name != 'bar') { |
| 2219 | return; |
| 2220 | } |
| 2221 | |
| 2222 | if (!self::is_for_this_post_type('attachment')) { |
| 2223 | return; |
| 2224 | } |
| 2225 | |
| 2226 | $current_term = false; |
| 2227 | if (isset($_REQUEST['media_folder'])) { |
| 2228 | $current_term = sanitize_text_field($_REQUEST['media_folder']); |
| 2229 | } |
| 2230 | |
| 2231 | wp_dropdown_categories( |
| 2232 | [ |
| 2233 | 'show_option_all' => esc_html__('All Folders', 'folders'), |
| 2234 | 'show_option_none' => esc_html__('(Unassigned)', 'folders'), |
| 2235 | 'option_none_value' => -1, |
| 2236 | 'orderby' => 'meta_value_num', |
| 2237 | 'order' => 'ASC', |
| 2238 | 'show_count' => true, |
| 2239 | 'hide_empty' => false, |
| 2240 | 'update_count_callback' => '_update_generic_term_count', |
| 2241 | 'echo' => true, |
| 2242 | 'selected' => $current_term, |
| 2243 | 'hierarchical' => true, |
| 2244 | 'name' => 'media_folder', |
| 2245 | 'id' => '', |
| 2246 | 'class' => '', |
| 2247 | 'taxonomy' => 'media_folder', |
| 2248 | 'value_field' => 'slug', |
| 2249 | 'meta_query' => [ |
| 2250 | [ |
| 2251 | 'key' => 'wcp_custom_order', |
| 2252 | 'type' => 'NUMERIC', |
| 2253 | ], |
| 2254 | ], |
| 2255 | ] |
| 2256 | ); |
| 2257 | |
| 2258 | }//end output_list_table_filters() |
| 2259 | |
| 2260 | |
| 2261 | /** |
| 2262 | * Update folder relationship with page, post, media |
| 2263 | * |
| 2264 | * @since 1.0.0 |
| 2265 | * @access public |
| 2266 | * @return $folders |
| 2267 | */ |
| 2268 | function new_to_auto_draft($post) |
| 2269 | { |
| 2270 | |
| 2271 | $post_type = $post->post_type; |
| 2272 | |
| 2273 | if (self::is_for_this_post_type($post_type) && !isset($_REQUEST["folder_for_media"])) { |
| 2274 | $post_type = self::get_custom_post_type($post_type); |
| 2275 | $selected_folder = get_option("selected_".esc_attr($post_type)."_folder"); |
| 2276 | |
| 2277 | if ($selected_folder != null && !empty($selected_folder)) { |
| 2278 | $terms = get_term($selected_folder); |
| 2279 | if (!empty($terms) && isset($terms->slug)) { |
| 2280 | wp_set_object_terms($post->ID, $terms->slug, $post_type); |
| 2281 | } |
| 2282 | } |
| 2283 | } |
| 2284 | |
| 2285 | }//end new_to_auto_draft() |
| 2286 | |
| 2287 | |
| 2288 | /** |
| 2289 | * Send message to owner for Help |
| 2290 | * |
| 2291 | * @since 1.0.0 |
| 2292 | * @access public |
| 2293 | * @return $response |
| 2294 | */ |
| 2295 | public function wcp_folder_send_message_to_owner() |
| 2296 | { |
| 2297 | if (current_user_can('manage_options')) { |
| 2298 | $response = []; |
| 2299 | $response['status'] = 0; |
| 2300 | $response['error'] = 0; |
| 2301 | $response['errors'] = []; |
| 2302 | $response['message'] = ""; |
| 2303 | $errorArray = []; |
| 2304 | $errorMessage = esc_html__("%s is required", 'folders'); |
| 2305 | $postData = filter_input_array(INPUT_POST); |
| 2306 | if (!isset($postData['textarea_text']) || trim($postData['textarea_text']) == "") { |
| 2307 | $error = [ |
| 2308 | "key" => "textarea_text", |
| 2309 | "message" => esc_html__("Please enter your message", 'folders'), |
| 2310 | ]; |
| 2311 | $errorArray[] = $error; |
| 2312 | } |
| 2313 | |
| 2314 | if (!isset($postData['user_email']) || trim($postData['user_email']) == "") { |
| 2315 | $error = [ |
| 2316 | "key" => "user_email", |
| 2317 | "message" => sprintf($errorMessage, __("Email", 'folders')), |
| 2318 | ]; |
| 2319 | $errorArray[] = $error; |
| 2320 | } else if (!filter_var($postData['user_email'], FILTER_VALIDATE_EMAIL)) { |
| 2321 | $error = [ |
| 2322 | 'key' => "user_email", |
| 2323 | "message" => "Email is not valid", |
| 2324 | ]; |
| 2325 | $errorArray[] = $error; |
| 2326 | } |
| 2327 | |
| 2328 | if (empty($errorArray)) { |
| 2329 | if (!isset($postData['folder_help_nonce']) || trim($postData['folder_help_nonce']) == "") { |
| 2330 | $error = [ |
| 2331 | "key" => "nonce", |
| 2332 | "message" => esc_html__("Your request is not valid", 'folders'), |
| 2333 | ]; |
| 2334 | $errorArray[] = $error; |
| 2335 | } else { |
| 2336 | if (!wp_verify_nonce($postData['folder_help_nonce'], 'wcp_folder_help_nonce')) { |
| 2337 | $error = [ |
| 2338 | "key" => "nonce", |
| 2339 | "message" => esc_html__("Your request is not valid", 'folders'), |
| 2340 | ]; |
| 2341 | $errorArray[] = $error; |
| 2342 | } |
| 2343 | } |
| 2344 | } |
| 2345 | |
| 2346 | if (empty($errorArray)) { |
| 2347 | $text_message = self::sanitize_options($postData['textarea_text']); |
| 2348 | $email = self::sanitize_options($postData['user_email'], "email"); |
| 2349 | $domain = site_url(); |
| 2350 | $current_user = wp_get_current_user(); |
| 2351 | $user_name = $current_user->first_name." ".$current_user->last_name; |
| 2352 | |
| 2353 | $response['status'] = 1; |
| 2354 | |
| 2355 | // sending message to Crisp |
| 2356 | $post_message = []; |
| 2357 | |
| 2358 | $message_data = []; |
| 2359 | $message_data['key'] = "Plugin"; |
| 2360 | $message_data['value'] = "Folders"; |
| 2361 | $post_message[] = $message_data; |
| 2362 | |
| 2363 | $message_data = []; |
| 2364 | $message_data['key'] = "Domain"; |
| 2365 | $message_data['value'] = $domain; |
| 2366 | $post_message[] = $message_data; |
| 2367 | |
| 2368 | $message_data = []; |
| 2369 | $message_data['key'] = "Email"; |
| 2370 | $message_data['value'] = $email; |
| 2371 | $post_message[] = $message_data; |
| 2372 | |
| 2373 | $message_data = []; |
| 2374 | $message_data['key'] = "Message"; |
| 2375 | $message_data['value'] = $text_message; |
| 2376 | $post_message[] = $message_data; |
| 2377 | |
| 2378 | $api_params = [ |
| 2379 | 'domain' => $domain, |
| 2380 | 'email' => $email, |
| 2381 | 'url' => site_url(), |
| 2382 | 'name' => $user_name, |
| 2383 | 'message' => $post_message, |
| 2384 | 'plugin' => "Folders", |
| 2385 | 'type' => "Need Help", |
| 2386 | ]; |
| 2387 | |
| 2388 | // Sending message to Crisp API |
| 2389 | $crisp_response = wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => true]); |
| 2390 | |
| 2391 | if (is_wp_error($crisp_response)) { |
| 2392 | wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => false]); |
| 2393 | } |
| 2394 | } else { |
| 2395 | $response['error'] = 1; |
| 2396 | $response['errors'] = $errorArray; |
| 2397 | }//end if |
| 2398 | |
| 2399 | echo json_encode($response); |
| 2400 | }//end if |
| 2401 | |
| 2402 | }//end wcp_folder_send_message_to_owner() |
| 2403 | |
| 2404 | |
| 2405 | /** |
| 2406 | * Send message to owner when folder is deactivated |
| 2407 | * |
| 2408 | * @since 1.0.0 |
| 2409 | * @access public |
| 2410 | * @return $response |
| 2411 | */ |
| 2412 | public function folder_plugin_deactivate() |
| 2413 | { |
| 2414 | if (current_user_can('manage_options')) { |
| 2415 | $postData = filter_input_array(INPUT_POST); |
| 2416 | $errorCounter = 0; |
| 2417 | $response = []; |
| 2418 | $response['status'] = 0; |
| 2419 | $response['message'] = ""; |
| 2420 | $response['valid'] = 1; |
| 2421 | if (!isset($postData['reason']) || empty($postData['reason'])) { |
| 2422 | $errorCounter++; |
| 2423 | $response['message'] = "Please provide reason"; |
| 2424 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 2425 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2426 | $errorCounter++; |
| 2427 | $response['valid'] = 0; |
| 2428 | } else { |
| 2429 | $nonce = self::sanitize_options($postData['nonce']); |
| 2430 | if (!wp_verify_nonce($nonce, 'wcp_folder_deactivate_nonce')) { |
| 2431 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2432 | $errorCounter++; |
| 2433 | $response['valid'] = 0; |
| 2434 | } |
| 2435 | } |
| 2436 | |
| 2437 | if ($errorCounter == 0) { |
| 2438 | $reason = $postData['reason']; |
| 2439 | $email = "none@none.none"; |
| 2440 | if (isset($postData['email_id']) && !empty($postData['email_id']) && filter_var($postData['email_id'], FILTER_VALIDATE_EMAIL)) { |
| 2441 | $email = $postData['email_id']; |
| 2442 | } |
| 2443 | |
| 2444 | $domain = site_url(); |
| 2445 | $current_user = wp_get_current_user(); |
| 2446 | $user_name = $current_user->first_name." ".$current_user->last_name; |
| 2447 | |
| 2448 | $response['status'] = 1; |
| 2449 | |
| 2450 | // sending message to Crisp |
| 2451 | $post_message = []; |
| 2452 | |
| 2453 | $message_data = []; |
| 2454 | $message_data['key'] = "Plugin"; |
| 2455 | $message_data['value'] = "Folders"; |
| 2456 | $post_message[] = $message_data; |
| 2457 | |
| 2458 | $message_data = []; |
| 2459 | $message_data['key'] = "Plugin Version"; |
| 2460 | $message_data['value'] = WCP_FOLDER_VERSION; |
| 2461 | $post_message[] = $message_data; |
| 2462 | |
| 2463 | $message_data = []; |
| 2464 | $message_data['key'] = "Domain"; |
| 2465 | $message_data['value'] = $domain; |
| 2466 | $post_message[] = $message_data; |
| 2467 | |
| 2468 | $message_data = []; |
| 2469 | $message_data['key'] = "Email"; |
| 2470 | $message_data['value'] = $email; |
| 2471 | $post_message[] = $message_data; |
| 2472 | |
| 2473 | $message_data = []; |
| 2474 | $message_data['key'] = "WordPress Version"; |
| 2475 | $message_data['value'] = esc_attr(get_bloginfo('version')); |
| 2476 | $post_message[] = $message_data; |
| 2477 | |
| 2478 | $message_data = []; |
| 2479 | $message_data['key'] = "PHP Version"; |
| 2480 | $message_data['value'] = PHP_VERSION; |
| 2481 | $post_message[] = $message_data; |
| 2482 | |
| 2483 | $message_data = []; |
| 2484 | $message_data['key'] = "Message"; |
| 2485 | $message_data['value'] = $reason; |
| 2486 | $post_message[] = $message_data; |
| 2487 | |
| 2488 | $api_params = [ |
| 2489 | 'domain' => $domain, |
| 2490 | 'email' => $email, |
| 2491 | 'url' => site_url(), |
| 2492 | 'name' => $user_name, |
| 2493 | 'message' => $post_message, |
| 2494 | 'plugin' => "Folders", |
| 2495 | 'type' => "Uninstall", |
| 2496 | ]; |
| 2497 | |
| 2498 | // Sending message to Crisp API |
| 2499 | $crisp_response = wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => true]); |
| 2500 | |
| 2501 | if (is_wp_error($crisp_response)) { |
| 2502 | wp_safe_remote_post("https://go.premio.io/crisp/crisp-send-message.php", ['body' => $api_params, 'timeout' => 15, 'sslverify' => false]); |
| 2503 | } |
| 2504 | }//end if |
| 2505 | |
| 2506 | echo json_encode($response); |
| 2507 | wp_die(); |
| 2508 | }//end if |
| 2509 | |
| 2510 | }//end folder_plugin_deactivate() |
| 2511 | |
| 2512 | |
| 2513 | /** |
| 2514 | * Returns total folders |
| 2515 | * |
| 2516 | * @since 1.0.0 |
| 2517 | * @access public |
| 2518 | * @return $total |
| 2519 | */ |
| 2520 | public static function ttl_fldrs() |
| 2521 | { |
| 2522 | $post_types = get_option('folders_settings'); |
| 2523 | $post_types = is_array($post_types) ? $post_types : []; |
| 2524 | $total = 0; |
| 2525 | foreach ($post_types as $post_type) { |
| 2526 | $post_type = self::get_custom_post_type($post_type); |
| 2527 | $total += wp_count_terms($post_type); |
| 2528 | } |
| 2529 | |
| 2530 | return $total; |
| 2531 | |
| 2532 | }//end ttl_fldrs() |
| 2533 | |
| 2534 | |
| 2535 | /** |
| 2536 | * Remove post |
| 2537 | * |
| 2538 | * @since 1.0.0 |
| 2539 | * @access public |
| 2540 | * @return $response |
| 2541 | */ |
| 2542 | public function wcp_remove_post_item() |
| 2543 | { |
| 2544 | $response = []; |
| 2545 | $response['status'] = 0; |
| 2546 | $response['error'] = 0; |
| 2547 | $response['data'] = []; |
| 2548 | $response['message'] = ""; |
| 2549 | $postData = filter_input_array(INPUT_POST); |
| 2550 | if (isset($postData['post_id']) && !empty($postData['post_id'])) { |
| 2551 | wp_delete_post($postData['post_id']); |
| 2552 | $response['status'] = 1; |
| 2553 | } |
| 2554 | |
| 2555 | echo json_encode($response); |
| 2556 | wp_die(); |
| 2557 | |
| 2558 | }//end wcp_remove_post_item() |
| 2559 | |
| 2560 | |
| 2561 | /** |
| 2562 | * Mark all folders |
| 2563 | * |
| 2564 | * @since 1.0.0 |
| 2565 | * @access public |
| 2566 | * @return $response |
| 2567 | */ |
| 2568 | public function wcp_change_all_status() |
| 2569 | { |
| 2570 | $response = []; |
| 2571 | $response['status'] = 0; |
| 2572 | $response['error'] = 0; |
| 2573 | $response['data'] = []; |
| 2574 | $response['message'] = ""; |
| 2575 | $postData = filter_input_array(INPUT_POST); |
| 2576 | $errorCounter = 0; |
| 2577 | if (!isset($postData['type']) || empty($postData['type'])) { |
| 2578 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2579 | $errorCounter++; |
| 2580 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 2581 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2582 | $errorCounter++; |
| 2583 | } else if (!current_user_can("manage_categories") || ($postData['type'] == "page" && !current_user_can("edit_pages"))) { |
| 2584 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 2585 | $errorCounter++; |
| 2586 | } else if (!current_user_can("manage_categories") || ($postData['type'] != "page" && !current_user_can("edit_posts"))) { |
| 2587 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 2588 | $errorCounter++; |
| 2589 | } else { |
| 2590 | $type = self::sanitize_options($postData['type']); |
| 2591 | $nonce = self::sanitize_options($postData['nonce']); |
| 2592 | if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) { |
| 2593 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2594 | $errorCounter++; |
| 2595 | } |
| 2596 | } |
| 2597 | |
| 2598 | if ($errorCounter == 0) { |
| 2599 | if (isset($postData['folders']) || !empty($postData['folders'])) { |
| 2600 | $status = isset($postData['status']) ? $postData['status'] : 0; |
| 2601 | $status = self::sanitize_options($status); |
| 2602 | $folders = self::sanitize_options($postData['folders']); |
| 2603 | $folders = trim($folders, ","); |
| 2604 | $folders = explode(",", $folders); |
| 2605 | foreach ($folders as $folder) { |
| 2606 | update_term_meta($folder, "is_active", $status); |
| 2607 | } |
| 2608 | } |
| 2609 | |
| 2610 | $response['status'] = 1; |
| 2611 | } |
| 2612 | |
| 2613 | echo json_encode($response); |
| 2614 | wp_die(); |
| 2615 | |
| 2616 | }//end wcp_change_all_status() |
| 2617 | |
| 2618 | |
| 2619 | /** |
| 2620 | * Change folder width |
| 2621 | * |
| 2622 | * @since 1.0.0 |
| 2623 | * @access public |
| 2624 | * @return $response |
| 2625 | */ |
| 2626 | public function wcp_change_post_width() |
| 2627 | { |
| 2628 | $response = []; |
| 2629 | $response['status'] = 0; |
| 2630 | $response['error'] = 0; |
| 2631 | $response['data'] = []; |
| 2632 | $response['message'] = ""; |
| 2633 | $postData = filter_input_array(INPUT_POST); |
| 2634 | $errorCounter = 0; |
| 2635 | if (!isset($postData['width']) || empty($postData['width'])) { |
| 2636 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2637 | $errorCounter++; |
| 2638 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 2639 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2640 | $errorCounter++; |
| 2641 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 2642 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2643 | $errorCounter++; |
| 2644 | } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) { |
| 2645 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 2646 | $errorCounter++; |
| 2647 | } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) { |
| 2648 | $response['message'] = esc_html__("You have not permission to update width", 'folders'); |
| 2649 | $errorCounter++; |
| 2650 | } else { |
| 2651 | $type = self::sanitize_options($postData['type']); |
| 2652 | $nonce = self::sanitize_options($postData['nonce']); |
| 2653 | if (!wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$type)) { |
| 2654 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2655 | $errorCounter++; |
| 2656 | } |
| 2657 | }//end if |
| 2658 | |
| 2659 | if ($errorCounter == 0) { |
| 2660 | $type = self::sanitize_options($postData['type']); |
| 2661 | $width = self::sanitize_options($postData['width'], "int"); |
| 2662 | $optionName = "wcp_dynamic_width_for_".$type; |
| 2663 | update_option($optionName, $width); |
| 2664 | $response['status'] = 1; |
| 2665 | } |
| 2666 | |
| 2667 | echo json_encode($response); |
| 2668 | wp_die(); |
| 2669 | |
| 2670 | }//end wcp_change_post_width() |
| 2671 | |
| 2672 | |
| 2673 | /** |
| 2674 | * Assign folder to multiple posts, pages, attachments |
| 2675 | * |
| 2676 | * @since 1.0.0 |
| 2677 | * @access public |
| 2678 | * @return $response |
| 2679 | */ |
| 2680 | public function wcp_change_multiple_post_folder() |
| 2681 | { |
| 2682 | $response = []; |
| 2683 | $response['status'] = 0; |
| 2684 | $response['error'] = 0; |
| 2685 | $response['data'] = []; |
| 2686 | $response['message'] = ""; |
| 2687 | $postData = filter_input_array(INPUT_POST); |
| 2688 | $errorCounter = 0; |
| 2689 | if (!isset($postData['post_ids']) || empty($postData['post_ids'])) { |
| 2690 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2691 | $errorCounter++; |
| 2692 | } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) { |
| 2693 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2694 | $errorCounter++; |
| 2695 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 2696 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2697 | $errorCounter++; |
| 2698 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 2699 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2700 | $errorCounter++; |
| 2701 | } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) { |
| 2702 | $response['message'] = esc_html__("You have not permission to update folder", 'folders'); |
| 2703 | $errorCounter++; |
| 2704 | } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) { |
| 2705 | $response['message'] = esc_html__("You have not permission to update folder", 'folders'); |
| 2706 | $errorCounter++; |
| 2707 | } else { |
| 2708 | $folder_id = self::sanitize_options($postData['folder_id']); |
| 2709 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$folder_id)) { |
| 2710 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2711 | $errorCounter++; |
| 2712 | } |
| 2713 | }//end if |
| 2714 | |
| 2715 | if ($errorCounter == 0) { |
| 2716 | $folderUndoSettings = []; |
| 2717 | $postID = self::sanitize_options($postData['post_ids']); |
| 2718 | $postID = trim($postID, ","); |
| 2719 | $folderID = self::sanitize_options($postData['folder_id']); |
| 2720 | $type = self::sanitize_options($postData['type']); |
| 2721 | $postArray = explode(",", $postID); |
| 2722 | $status = 0; |
| 2723 | if (isset($postData['status'])) { |
| 2724 | $status = self::sanitize_options($postData['status']); |
| 2725 | } |
| 2726 | |
| 2727 | $status = true; |
| 2728 | |
| 2729 | $taxonomy = ""; |
| 2730 | if (isset($postData['taxonomy'])) { |
| 2731 | $taxonomy = self::sanitize_options($postData['taxonomy']); |
| 2732 | } |
| 2733 | |
| 2734 | if (is_array($postArray)) { |
| 2735 | $post_type = self::get_custom_post_type($type); |
| 2736 | foreach ($postArray as $post) { |
| 2737 | $terms = get_the_terms($post, $post_type); |
| 2738 | $post_terms = [ |
| 2739 | 'post_id' => $post, |
| 2740 | 'terms' => $terms, |
| 2741 | ]; |
| 2742 | $folderUndoSettings[] = $post_terms; |
| 2743 | if (!empty($terms)) { |
| 2744 | foreach ($terms as $term) { |
| 2745 | if (!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) { |
| 2746 | wp_remove_object_terms($post, $term->term_id, $post_type); |
| 2747 | } |
| 2748 | } |
| 2749 | } |
| 2750 | |
| 2751 | wp_set_post_terms($post, $folderID, $post_type, $status); |
| 2752 | } |
| 2753 | } |
| 2754 | |
| 2755 | $response['status'] = 1; |
| 2756 | delete_transient("folder_undo_settings"); |
| 2757 | delete_transient("premio_folders_without_trash"); |
| 2758 | set_transient("folder_undo_settings", $folderUndoSettings, DAY_IN_SECONDS); |
| 2759 | }//end if |
| 2760 | |
| 2761 | echo json_encode($response); |
| 2762 | wp_die(); |
| 2763 | |
| 2764 | }//end wcp_change_multiple_post_folder() |
| 2765 | |
| 2766 | |
| 2767 | /** |
| 2768 | * Undo folder changes |
| 2769 | * |
| 2770 | * @since 1.0.0 |
| 2771 | * @access public |
| 2772 | * @return $response |
| 2773 | */ |
| 2774 | public function wcp_undo_folder_changes() |
| 2775 | { |
| 2776 | $response = []; |
| 2777 | $response['status'] = 0; |
| 2778 | $response['error'] = 0; |
| 2779 | $response['data'] = []; |
| 2780 | $response['message'] = ""; |
| 2781 | $postData = filter_input_array(INPUT_POST); |
| 2782 | $errorCounter = 0; |
| 2783 | if (!isset($postData['post_type']) || empty($postData['post_type'])) { |
| 2784 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2785 | $errorCounter++; |
| 2786 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 2787 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2788 | $errorCounter++; |
| 2789 | } else { |
| 2790 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$postData['post_type'])) { |
| 2791 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2792 | $errorCounter++; |
| 2793 | } |
| 2794 | } |
| 2795 | |
| 2796 | if ($errorCounter == 0) { |
| 2797 | $response['status'] = 1; |
| 2798 | $folder_undo_settings = get_transient("folder_undo_settings"); |
| 2799 | $type = self::sanitize_options($postData['post_type']); |
| 2800 | $post_type = self::get_custom_post_type($type); |
| 2801 | if (!empty($folder_undo_settings) && is_array($folder_undo_settings)) { |
| 2802 | $trash_folders = $initial_trash_folders = get_transient("premio_folders_without_trash"); |
| 2803 | if ($trash_folders === false) { |
| 2804 | $trash_folders = []; |
| 2805 | $initial_trash_folders = []; |
| 2806 | } |
| 2807 | |
| 2808 | foreach ($folder_undo_settings as $item) { |
| 2809 | $terms = get_the_terms($item['post_id'], $post_type); |
| 2810 | if (!empty($terms)) { |
| 2811 | foreach ($terms as $term) { |
| 2812 | wp_remove_object_terms($item['post_id'], $term->term_id, $post_type); |
| 2813 | if (isset($trash_folders[$term->term_taxonomy_id])) { |
| 2814 | unset($trash_folders[$term->term_taxonomy_id]); |
| 2815 | } |
| 2816 | } |
| 2817 | } |
| 2818 | |
| 2819 | if (!empty($item['terms']) && is_array($item['terms'])) { |
| 2820 | foreach ($item['terms'] as $term) { |
| 2821 | wp_set_post_terms($item['post_id'], $term->term_id, $post_type, true); |
| 2822 | if (isset($trash_folders[$term->term_taxonomy_id])) { |
| 2823 | unset($trash_folders[$term->term_taxonomy_id]); |
| 2824 | } |
| 2825 | } |
| 2826 | } |
| 2827 | } |
| 2828 | |
| 2829 | if (!empty($terms) && $initial_trash_folders != $trash_folders) { |
| 2830 | delete_transient("premio_folders_without_trash"); |
| 2831 | set_transient("premio_folders_without_trash", $trash_folders, (3 * DAY_IN_SECONDS)); |
| 2832 | } |
| 2833 | }//end if |
| 2834 | }//end if |
| 2835 | |
| 2836 | echo json_encode($response); |
| 2837 | die; |
| 2838 | |
| 2839 | }//end wcp_undo_folder_changes() |
| 2840 | |
| 2841 | |
| 2842 | /** |
| 2843 | * Change post, page, attachment folder |
| 2844 | * |
| 2845 | * @since 1.0.0 |
| 2846 | * @access public |
| 2847 | * @return $response |
| 2848 | */ |
| 2849 | public function wcp_change_post_folder() |
| 2850 | { |
| 2851 | $response = []; |
| 2852 | $response['status'] = 0; |
| 2853 | $response['error'] = 0; |
| 2854 | $response['data'] = []; |
| 2855 | $response['message'] = ""; |
| 2856 | $postData = filter_input_array(INPUT_POST); |
| 2857 | $errorCounter = 0; |
| 2858 | if (!isset($postData['post_id']) || empty($postData['post_id'])) { |
| 2859 | $errorCounter++; |
| 2860 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2861 | } else if (!isset($postData['folder_id']) || empty($postData['folder_id'])) { |
| 2862 | $errorCounter++; |
| 2863 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2864 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 2865 | $errorCounter++; |
| 2866 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2867 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 2868 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2869 | $errorCounter++; |
| 2870 | } else if ($postData['type'] == "page" && !current_user_can("edit_pages")) { |
| 2871 | $response['message'] = esc_html__("You have not permission to update folder", 'folders'); |
| 2872 | $errorCounter++; |
| 2873 | } else if ($postData['type'] != "page" && !current_user_can("edit_posts")) { |
| 2874 | $response['message'] = esc_html__("You have not permission to update folder", 'folders'); |
| 2875 | $errorCounter++; |
| 2876 | } else { |
| 2877 | $term_id = self::sanitize_options($postData['folder_id']); |
| 2878 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) { |
| 2879 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2880 | $errorCounter++; |
| 2881 | } |
| 2882 | }//end if |
| 2883 | |
| 2884 | if ($errorCounter == 0) { |
| 2885 | $postID = self::sanitize_options($postData['post_id']); |
| 2886 | $folderID = self::sanitize_options($postData['folder_id']); |
| 2887 | $type = self::sanitize_options($postData['type']); |
| 2888 | $folder_post_type = self::get_custom_post_type($type); |
| 2889 | $status = 0; |
| 2890 | if (isset($postData['status'])) { |
| 2891 | $status = self::sanitize_options($postData['status']); |
| 2892 | } |
| 2893 | |
| 2894 | $status = ($status == 1) ? true : false; |
| 2895 | $taxonomy = ""; |
| 2896 | if (isset($postData['taxonomy'])) { |
| 2897 | $taxonomy = self::sanitize_options($postData['taxonomy']); |
| 2898 | } |
| 2899 | |
| 2900 | $terms = get_the_terms($postID, $folder_post_type); |
| 2901 | if (!empty($terms)) { |
| 2902 | foreach ($terms as $term) { |
| 2903 | if (!empty($taxonomy) && ($term->term_id == $taxonomy || $term->slug == $taxonomy)) { |
| 2904 | wp_remove_object_terms($postID, $term->term_id, $folder_post_type); |
| 2905 | } |
| 2906 | } |
| 2907 | } |
| 2908 | |
| 2909 | wp_set_post_terms($postID, $folderID, $folder_post_type, true); |
| 2910 | $response['status'] = 1; |
| 2911 | }//end if |
| 2912 | |
| 2913 | echo json_encode($response); |
| 2914 | wp_die(); |
| 2915 | |
| 2916 | }//end wcp_change_post_folder() |
| 2917 | |
| 2918 | |
| 2919 | /** |
| 2920 | * Mark/Unmark folder |
| 2921 | * |
| 2922 | * @since 1.0.0 |
| 2923 | * @access public |
| 2924 | * @return $response |
| 2925 | */ |
| 2926 | public function wcp_mark_un_mark_folder() |
| 2927 | { |
| 2928 | $response = []; |
| 2929 | $response['status'] = 0; |
| 2930 | $response['error'] = 0; |
| 2931 | $response['data'] = []; |
| 2932 | $response['message'] = ""; |
| 2933 | $postData = filter_input_array(INPUT_POST); |
| 2934 | $errorCounter = 0; |
| 2935 | if (!current_user_can("manage_categories")) { |
| 2936 | $response['message'] = esc_html__("You have not permission to update folder", 'folders'); |
| 2937 | $errorCounter++; |
| 2938 | } else if (!isset($postData['term_id']) || empty($postData['term_id'])) { |
| 2939 | $errorCounter++; |
| 2940 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2941 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 2942 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2943 | $errorCounter++; |
| 2944 | } else { |
| 2945 | $term_id = self::sanitize_options($postData['term_id']); |
| 2946 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) { |
| 2947 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2948 | $errorCounter++; |
| 2949 | } |
| 2950 | } |
| 2951 | |
| 2952 | if ($errorCounter == 0) { |
| 2953 | $term_id = self::sanitize_options($postData['term_id']); |
| 2954 | $status = get_term_meta($term_id, "is_highlighted", true); |
| 2955 | if ($status == 1) { |
| 2956 | update_term_meta($term_id, "is_highlighted", 0); |
| 2957 | $status = 0; |
| 2958 | } else { |
| 2959 | update_term_meta($term_id, "is_highlighted", 1); |
| 2960 | $status = 1; |
| 2961 | } |
| 2962 | |
| 2963 | $response['marked'] = $status; |
| 2964 | $response['id'] = $postData['term_id']; |
| 2965 | $response['status'] = 1; |
| 2966 | } |
| 2967 | |
| 2968 | echo json_encode($response); |
| 2969 | wp_die(); |
| 2970 | |
| 2971 | }//end wcp_mark_un_mark_folder() |
| 2972 | |
| 2973 | |
| 2974 | /** |
| 2975 | * Make folder Sticky |
| 2976 | * |
| 2977 | * @since 1.0.0 |
| 2978 | * @access public |
| 2979 | * @return $response |
| 2980 | */ |
| 2981 | public function wcp_make_sticky_folder() |
| 2982 | { |
| 2983 | $response = []; |
| 2984 | $response['status'] = 0; |
| 2985 | $response['error'] = 0; |
| 2986 | $response['data'] = []; |
| 2987 | $response['message'] = ""; |
| 2988 | $postData = filter_input_array(INPUT_POST); |
| 2989 | $errorCounter = 0; |
| 2990 | if (!current_user_can("manage_categories")) { |
| 2991 | $response['message'] = esc_html__("You have not permission to update folder", 'folders'); |
| 2992 | $errorCounter++; |
| 2993 | } else if (!isset($postData['term_id']) || empty($postData['term_id'])) { |
| 2994 | $errorCounter++; |
| 2995 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2996 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 2997 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 2998 | $errorCounter++; |
| 2999 | } else { |
| 3000 | $term_id = self::sanitize_options($postData['term_id']); |
| 3001 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) { |
| 3002 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3003 | $errorCounter++; |
| 3004 | } |
| 3005 | } |
| 3006 | |
| 3007 | if ($errorCounter == 0) { |
| 3008 | $term_id = self::sanitize_options($postData['term_id']); |
| 3009 | $status = get_term_meta($term_id, "is_folder_sticky", true); |
| 3010 | if ($status == 1) { |
| 3011 | update_term_meta($term_id, "is_folder_sticky", 0); |
| 3012 | $status = 0; |
| 3013 | } else { |
| 3014 | update_term_meta($term_id, "is_folder_sticky", 1); |
| 3015 | $status = 1; |
| 3016 | } |
| 3017 | |
| 3018 | $response['is_folder_sticky'] = $status; |
| 3019 | $response['id'] = $postData['term_id']; |
| 3020 | $response['status'] = 1; |
| 3021 | } |
| 3022 | |
| 3023 | echo json_encode($response); |
| 3024 | wp_die(); |
| 3025 | |
| 3026 | }//end wcp_make_sticky_folder() |
| 3027 | |
| 3028 | |
| 3029 | /** |
| 3030 | * Save folder order |
| 3031 | * |
| 3032 | * @since 1.0.0 |
| 3033 | * @access public |
| 3034 | * @return $response |
| 3035 | */ |
| 3036 | public function wcp_save_folder_order() |
| 3037 | { |
| 3038 | $response = []; |
| 3039 | $response['status'] = 0; |
| 3040 | $response['error'] = 0; |
| 3041 | $response['data'] = []; |
| 3042 | $response['message'] = ""; |
| 3043 | $postData = filter_input_array(INPUT_POST); |
| 3044 | $errorCounter = 0; |
| 3045 | if (!current_user_can("manage_categories")) { |
| 3046 | $response['message'] = esc_html__("You have not permission to update folder order", 'folders'); |
| 3047 | $errorCounter++; |
| 3048 | } else if (!isset($postData['term_ids']) || empty($postData['term_ids'])) { |
| 3049 | $errorCounter++; |
| 3050 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3051 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 3052 | $errorCounter++; |
| 3053 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3054 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 3055 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3056 | $errorCounter++; |
| 3057 | } else { |
| 3058 | $type = self::sanitize_options($postData['type']); |
| 3059 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) { |
| 3060 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3061 | $errorCounter++; |
| 3062 | } |
| 3063 | } |
| 3064 | |
| 3065 | if ($errorCounter == 0) { |
| 3066 | $termIds = self::sanitize_options(($postData['term_ids'])); |
| 3067 | $type = self::sanitize_options($postData['type']); |
| 3068 | $termIds = trim($termIds, ","); |
| 3069 | $termArray = explode(",", $termIds); |
| 3070 | $order = 1; |
| 3071 | foreach ($termArray as $term) { |
| 3072 | if (!empty($term)) { |
| 3073 | update_term_meta($term, "wcp_custom_order", $order); |
| 3074 | $order++; |
| 3075 | } |
| 3076 | } |
| 3077 | |
| 3078 | $term_id = self::sanitize_options($postData['term_id']); |
| 3079 | $parent_id = self::sanitize_options($postData['parent_id']); |
| 3080 | $type = self::sanitize_options($postData['type']); |
| 3081 | $folder_type = self::get_custom_post_type($type); |
| 3082 | wp_update_term( |
| 3083 | $term_id, |
| 3084 | $folder_type, |
| 3085 | ['parent' => $parent_id] |
| 3086 | ); |
| 3087 | |
| 3088 | if ($parent_id != "#" || !empty($parent_id)) { |
| 3089 | update_term_meta($parent_id, "is_active", 1); |
| 3090 | } |
| 3091 | |
| 3092 | $response['status'] = 1; |
| 3093 | $folder_type = self::get_custom_post_type($type); |
| 3094 | // Free/Pro Class name change |
| 3095 | $response['options'] = WCP_Tree::get_option_data_for_select($folder_type); |
| 3096 | }//end if |
| 3097 | |
| 3098 | echo json_encode($response); |
| 3099 | wp_die(); |
| 3100 | |
| 3101 | }//end wcp_save_folder_order() |
| 3102 | |
| 3103 | |
| 3104 | /** |
| 3105 | * Make folder State open/closed |
| 3106 | * |
| 3107 | * @since 1.0.0 |
| 3108 | * @access public |
| 3109 | * @return $response |
| 3110 | */ |
| 3111 | public function save_wcp_folder_state() |
| 3112 | { |
| 3113 | $response = []; |
| 3114 | $response['status'] = 0; |
| 3115 | $response['error'] = 0; |
| 3116 | $response['data'] = []; |
| 3117 | $response['message'] = ""; |
| 3118 | $postData = filter_input_array(INPUT_POST); |
| 3119 | $errorCounter = 0; |
| 3120 | if (!current_user_can("manage_categories")) { |
| 3121 | $response['message'] = esc_html__("You have not permission to update folder", 'folders'); |
| 3122 | $errorCounter++; |
| 3123 | } else if (!isset($postData['term_id']) || empty($postData['term_id'])) { |
| 3124 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3125 | $errorCounter++; |
| 3126 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 3127 | $response['message'] = esc_html__("Unable to create folder, Your request is not valid", 'folders'); |
| 3128 | $errorCounter++; |
| 3129 | } else { |
| 3130 | $term_id = self::sanitize_options($postData['term_id']); |
| 3131 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) { |
| 3132 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3133 | $errorCounter++; |
| 3134 | } |
| 3135 | } |
| 3136 | |
| 3137 | if ($errorCounter == 0) { |
| 3138 | $response['status'] = 1; |
| 3139 | $term_id = self::sanitize_options($postData['term_id']); |
| 3140 | $is_active = isset($postData['is_active']) ? $postData['is_active'] : 0; |
| 3141 | $is_active = self::sanitize_options($is_active); |
| 3142 | if ($is_active == 1) { |
| 3143 | update_term_meta($term_id, "is_active", 1); |
| 3144 | } else { |
| 3145 | update_term_meta($term_id, "is_active", 0); |
| 3146 | } |
| 3147 | } |
| 3148 | |
| 3149 | echo json_encode($response); |
| 3150 | wp_die(); |
| 3151 | |
| 3152 | }//end save_wcp_folder_state() |
| 3153 | |
| 3154 | |
| 3155 | /** |
| 3156 | * Save parent folder information with order |
| 3157 | * |
| 3158 | * @since 1.0.0 |
| 3159 | * @access public |
| 3160 | * @return $response |
| 3161 | */ |
| 3162 | public function wcp_update_parent_information() |
| 3163 | { |
| 3164 | $response = []; |
| 3165 | $response['status'] = 0; |
| 3166 | $response['error'] = 0; |
| 3167 | $response['data'] = []; |
| 3168 | $response['message'] = ""; |
| 3169 | $postData = filter_input_array(INPUT_POST); |
| 3170 | $errorCounter = 0; |
| 3171 | if (!current_user_can("manage_categories")) { |
| 3172 | $response['message'] = esc_html__("You have not permission to update folder", 'folders'); |
| 3173 | $errorCounter++; |
| 3174 | } else if (!isset($postData['term_id']) || empty($postData['term_id'])) { |
| 3175 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3176 | $errorCounter++; |
| 3177 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 3178 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3179 | $errorCounter++; |
| 3180 | } else if (!isset($postData['parent_id'])) { |
| 3181 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3182 | $errorCounter++; |
| 3183 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 3184 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3185 | $errorCounter++; |
| 3186 | } else { |
| 3187 | $term_id = self::sanitize_options($postData['term_id']); |
| 3188 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) { |
| 3189 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3190 | $errorCounter++; |
| 3191 | } |
| 3192 | }//end if |
| 3193 | |
| 3194 | if ($errorCounter == 0) { |
| 3195 | $term_id = self::sanitize_options($postData['term_id']); |
| 3196 | $parent_id = self::sanitize_options($postData['parent_id']); |
| 3197 | $type = self::sanitize_options($postData['type']); |
| 3198 | $folder_type = self::get_custom_post_type($type); |
| 3199 | wp_update_term( |
| 3200 | $term_id, |
| 3201 | $folder_type, |
| 3202 | ['parent' => $parent_id] |
| 3203 | ); |
| 3204 | update_term_meta($parent_id, "is_active", 1); |
| 3205 | $response['status'] = 1; |
| 3206 | } |
| 3207 | |
| 3208 | echo json_encode($response); |
| 3209 | wp_die(); |
| 3210 | |
| 3211 | }//end wcp_update_parent_information() |
| 3212 | |
| 3213 | |
| 3214 | /** |
| 3215 | * Save parent folder data |
| 3216 | * |
| 3217 | * @since 1.0.0 |
| 3218 | * @access public |
| 3219 | * @return $response |
| 3220 | */ |
| 3221 | public function wcp_save_parent_data() |
| 3222 | { |
| 3223 | $response = []; |
| 3224 | $response['status'] = 0; |
| 3225 | $response['error'] = 0; |
| 3226 | $response['data'] = []; |
| 3227 | $response['message'] = ""; |
| 3228 | $postData = filter_input_array(INPUT_POST); |
| 3229 | $errorCounter = 0; |
| 3230 | if (!isset($postData['type']) || empty($postData['type'])) { |
| 3231 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3232 | $errorCounter++; |
| 3233 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 3234 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3235 | $errorCounter++; |
| 3236 | } else if (!current_user_can("manage_categories")) { |
| 3237 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3238 | $errorCounter++; |
| 3239 | } else { |
| 3240 | $type = self::sanitize_options($postData['type']); |
| 3241 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) { |
| 3242 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3243 | $errorCounter++; |
| 3244 | } |
| 3245 | } |
| 3246 | |
| 3247 | if ($errorCounter == 0) { |
| 3248 | $type = self::sanitize_options($postData['type']); |
| 3249 | $optionName = $type."_parent_status"; |
| 3250 | $response['status'] = 1; |
| 3251 | $is_active = isset($postData['is_active']) ? $postData['is_active'] : 0; |
| 3252 | $is_active = self::sanitize_options($is_active); |
| 3253 | if ($is_active == 1) { |
| 3254 | update_option($optionName, 1); |
| 3255 | } else { |
| 3256 | update_option($optionName, 0); |
| 3257 | } |
| 3258 | } |
| 3259 | |
| 3260 | echo json_encode($response); |
| 3261 | wp_die(); |
| 3262 | |
| 3263 | }//end wcp_save_parent_data() |
| 3264 | |
| 3265 | |
| 3266 | /** |
| 3267 | * Remove multiple folders |
| 3268 | * |
| 3269 | * @since 1.0.0 |
| 3270 | * @access public |
| 3271 | * @return $response |
| 3272 | */ |
| 3273 | public function remove_muliple_folder() |
| 3274 | { |
| 3275 | $response = []; |
| 3276 | $response['status'] = 0; |
| 3277 | $response['error'] = 0; |
| 3278 | $response['data'] = []; |
| 3279 | $response['message'] = ""; |
| 3280 | $postData = filter_input_array(INPUT_POST); |
| 3281 | $errorCounter = 0; |
| 3282 | $error = ""; |
| 3283 | if (!current_user_can("manage_categories")) { |
| 3284 | $error = esc_html__("You have not permission to remove folder", 'folders'); |
| 3285 | $errorCounter++; |
| 3286 | } else if (!isset($postData['term_id']) || empty($postData['term_id'])) { |
| 3287 | $error = esc_html__("Your request is not valid", 'folders'); |
| 3288 | $errorCounter++; |
| 3289 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 3290 | $error = esc_html__("Your request is not valid", 'folders'); |
| 3291 | $errorCounter++; |
| 3292 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 3293 | $response['message'] = esc_html__("Your request is not valid", 'folders'); |
| 3294 | $errorCounter++; |
| 3295 | } else { |
| 3296 | $type = self::sanitize_options($postData['type']); |
| 3297 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) { |
| 3298 | $error = esc_html__("Your request is not valid", 'folders'); |
| 3299 | $errorCounter++; |
| 3300 | } |
| 3301 | } |
| 3302 | |
| 3303 | if ($errorCounter == 0) { |
| 3304 | $term_id = self::sanitize_options($postData['term_id']); |
| 3305 | $type = self::sanitize_options($postData['type']); |
| 3306 | $response['term_ids'] = []; |
| 3307 | if (!empty($term_id)) { |
| 3308 | $term_id = trim($term_id, ","); |
| 3309 | $term_ids = explode(",", $term_id); |
| 3310 | if (is_array($term_ids) && count($term_ids) > 0) { |
| 3311 | foreach ($term_ids as $term) { |
| 3312 | self::remove_folder_child_items($term, $type); |
| 3313 | } |
| 3314 | |
| 3315 | $response['term_ids'] = $term_ids; |
| 3316 | } |
| 3317 | } |
| 3318 | |
| 3319 | $is_active = 1; |
| 3320 | $folders = -1; |
| 3321 | $response['status'] = 1; |
| 3322 | $response['folders'] = $folders; |
| 3323 | $response['is_key_active'] = $is_active; |
| 3324 | } else { |
| 3325 | $response['error'] = 1; |
| 3326 | $response['message'] = $error; |
| 3327 | }//end if |
| 3328 | |
| 3329 | echo json_encode($response); |
| 3330 | wp_die(); |
| 3331 | |
| 3332 | }//end remove_muliple_folder() |
| 3333 | |
| 3334 | |
| 3335 | /** |
| 3336 | * Remove folder |
| 3337 | * |
| 3338 | * @since 1.0.0 |
| 3339 | * @access public |
| 3340 | * @return $response |
| 3341 | */ |
| 3342 | public function wcp_remove_folder() |
| 3343 | { |
| 3344 | $response = []; |
| 3345 | $response['status'] = 0; |
| 3346 | $response['error'] = 0; |
| 3347 | $response['data'] = []; |
| 3348 | $response['message'] = ""; |
| 3349 | $postData = filter_input_array(INPUT_POST); |
| 3350 | $errorCounter = 0; |
| 3351 | if (!current_user_can("manage_categories")) { |
| 3352 | $error = esc_html__("You have not permission to remove folder", 'folders'); |
| 3353 | $errorCounter++; |
| 3354 | } else if (!isset($postData['term_id']) || empty($postData['term_id'])) { |
| 3355 | $error = esc_html__("Your request is not valid", 'folders'); |
| 3356 | $errorCounter++; |
| 3357 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 3358 | $error = esc_html__("Your request is not valid", 'folders'); |
| 3359 | $errorCounter++; |
| 3360 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 3361 | $error = esc_html__("Unable to delete folder, Your request is not valid", 'folders'); |
| 3362 | $errorCounter++; |
| 3363 | } else { |
| 3364 | $term_id = self::sanitize_options($postData['term_id']); |
| 3365 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) { |
| 3366 | $error = esc_html__("Unable to delete folder, Your request is not valid", 'folders'); |
| 3367 | $errorCounter++; |
| 3368 | } |
| 3369 | } |
| 3370 | |
| 3371 | if ($errorCounter == 0) { |
| 3372 | $term_id = self::sanitize_options($postData['term_id']); |
| 3373 | $type = self::sanitize_options($postData['type']); |
| 3374 | self::remove_folder_child_items($term_id, $type); |
| 3375 | $response['status'] = 1; |
| 3376 | $is_active = 1; |
| 3377 | $folders = -1; |
| 3378 | $response['folders'] = $folders; |
| 3379 | $response['term_id'] = $term_id; |
| 3380 | $response['is_key_active'] = $is_active; |
| 3381 | } else { |
| 3382 | $response['error'] = 1; |
| 3383 | $response['message'] = $error; |
| 3384 | } |
| 3385 | |
| 3386 | echo json_encode($response); |
| 3387 | wp_die(); |
| 3388 | |
| 3389 | }//end wcp_remove_folder() |
| 3390 | |
| 3391 | |
| 3392 | /** |
| 3393 | * Remove folders for page, post, attachment |
| 3394 | * |
| 3395 | * @since 1.0.0 |
| 3396 | * @access public |
| 3397 | * @return $response |
| 3398 | */ |
| 3399 | public function remove_folder_child_items($term_id, $post_type) |
| 3400 | { |
| 3401 | $folder_type = self::get_custom_post_type($post_type); |
| 3402 | $terms = get_terms( |
| 3403 | $folder_type, |
| 3404 | [ |
| 3405 | 'hide_empty' => false, |
| 3406 | 'parent' => $term_id, |
| 3407 | ] |
| 3408 | ); |
| 3409 | |
| 3410 | if (!empty($terms)) { |
| 3411 | foreach ($terms as $term) { |
| 3412 | self::remove_folder_child_items($term->term_id, $post_type); |
| 3413 | } |
| 3414 | |
| 3415 | wp_delete_term($term_id, $folder_type); |
| 3416 | } else { |
| 3417 | wp_delete_term($term_id, $folder_type); |
| 3418 | } |
| 3419 | |
| 3420 | }//end remove_folder_child_items() |
| 3421 | |
| 3422 | |
| 3423 | /** |
| 3424 | * Update Folder |
| 3425 | * |
| 3426 | * @since 1.0.0 |
| 3427 | * @access public |
| 3428 | * @return $response |
| 3429 | */ |
| 3430 | public function wcp_update_folder() |
| 3431 | { |
| 3432 | $response = []; |
| 3433 | $response['status'] = 0; |
| 3434 | $response['error'] = 0; |
| 3435 | $response['data'] = []; |
| 3436 | $response['message'] = ""; |
| 3437 | $postData = filter_input_array(INPUT_POST); |
| 3438 | $errorCounter = 0; |
| 3439 | if (!current_user_can("manage_categories")) { |
| 3440 | $error = esc_html__("You have not permission to update folder", 'folders'); |
| 3441 | $errorCounter++; |
| 3442 | } else if (!isset($postData['term_id']) || empty($postData['term_id'])) { |
| 3443 | $error = esc_html__("Unable to rename folder, Your request is not valid", 'folders'); |
| 3444 | $errorCounter++; |
| 3445 | } else if (!isset($postData['name']) || empty($postData['name'])) { |
| 3446 | $error = esc_html__("Folder name can no be empty", 'folders'); |
| 3447 | $errorCounter++; |
| 3448 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 3449 | $error = esc_html__("Your request is not valid", 'folders'); |
| 3450 | $errorCounter++; |
| 3451 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 3452 | $error = esc_html__("Unable to rename folder, Your request is not valid", 'folders'); |
| 3453 | $errorCounter++; |
| 3454 | } else { |
| 3455 | $term_id = self::sanitize_options($postData['term_id']); |
| 3456 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_term_'.$term_id)) { |
| 3457 | $error = esc_html__("Unable to rename folder, Your request is not valid", 'folders'); |
| 3458 | $errorCounter++; |
| 3459 | } |
| 3460 | }//end if |
| 3461 | |
| 3462 | if ($errorCounter == 0) { |
| 3463 | $type = self::sanitize_options($postData['type']); |
| 3464 | $folder_type = self::get_custom_post_type($type); |
| 3465 | $name = self::sanitize_options($postData['name']); |
| 3466 | $term_id = self::sanitize_options($postData['term_id']); |
| 3467 | $result = wp_update_term( |
| 3468 | $term_id, |
| 3469 | $folder_type, |
| 3470 | ['name' => $name] |
| 3471 | ); |
| 3472 | if (!empty($result)) { |
| 3473 | $term_nonce = wp_create_nonce('wcp_folder_term_'.$result['term_id']); |
| 3474 | $response['id'] = $result['term_id']; |
| 3475 | $response['slug'] = $result['slug']; |
| 3476 | $response['status'] = 1; |
| 3477 | $response['term_title'] = $postData['name']; |
| 3478 | $response['nonce'] = $term_nonce; |
| 3479 | } else { |
| 3480 | $response['message'] = esc_html__("Unable to rename folder", 'folders'); |
| 3481 | } |
| 3482 | } else { |
| 3483 | $response['error'] = 1; |
| 3484 | $response['message'] = $error; |
| 3485 | }//end if |
| 3486 | |
| 3487 | echo json_encode($response); |
| 3488 | wp_die(); |
| 3489 | |
| 3490 | }//end wcp_update_folder() |
| 3491 | |
| 3492 | |
| 3493 | /** |
| 3494 | * Create slug from string |
| 3495 | * |
| 3496 | * @since 1.0.0 |
| 3497 | * @access public |
| 3498 | * @return $slug |
| 3499 | */ |
| 3500 | public function create_slug_from_string($str) |
| 3501 | { |
| 3502 | $a = [ |
| 3503 | 'À', |
| 3504 | 'Á', |
| 3505 | 'Â', |
| 3506 | 'Ã', |
| 3507 | 'Ä', |
| 3508 | '� |
| 3509 | ', |
| 3510 | 'Æ', |
| 3511 | 'Ç', |
| 3512 | 'È', |
| 3513 | 'É', |
| 3514 | 'Ê', |
| 3515 | 'Ë', |
| 3516 | 'Ì', |
| 3517 | 'Í', |
| 3518 | 'Î', |
| 3519 | 'Ï', |
| 3520 | 'Ð', |
| 3521 | 'Ñ', |
| 3522 | 'Ò', |
| 3523 | 'Ó', |
| 3524 | 'Ô', |
| 3525 | 'Õ', |
| 3526 | 'Ö', |
| 3527 | 'Ø', |
| 3528 | 'Ù', |
| 3529 | 'Ú', |
| 3530 | 'Û', |
| 3531 | 'Ü', |
| 3532 | 'Ý', |
| 3533 | 'ß', |
| 3534 | 'à', |
| 3535 | 'á', |
| 3536 | 'â', |
| 3537 | 'ã', |
| 3538 | 'ä', |
| 3539 | 'å', |
| 3540 | 'æ', |
| 3541 | 'ç', |
| 3542 | 'è', |
| 3543 | 'é', |
| 3544 | 'ê', |
| 3545 | 'ë', |
| 3546 | 'ì', |
| 3547 | 'í', |
| 3548 | 'î', |
| 3549 | 'ï', |
| 3550 | 'ñ', |
| 3551 | 'ò', |
| 3552 | 'ó', |
| 3553 | 'ô', |
| 3554 | 'õ', |
| 3555 | 'ö', |
| 3556 | 'ø', |
| 3557 | 'ù', |
| 3558 | 'ú', |
| 3559 | 'û', |
| 3560 | 'ü', |
| 3561 | 'ý', |
| 3562 | 'ÿ', |
| 3563 | 'A', |
| 3564 | 'a', |
| 3565 | 'A', |
| 3566 | 'a', |
| 3567 | 'A', |
| 3568 | 'a', |
| 3569 | 'C', |
| 3570 | 'c', |
| 3571 | 'C', |
| 3572 | 'c', |
| 3573 | 'C', |
| 3574 | 'c', |
| 3575 | 'C', |
| 3576 | 'c', |
| 3577 | 'D', |
| 3578 | 'd', |
| 3579 | 'Ð', |
| 3580 | 'd', |
| 3581 | 'E', |
| 3582 | 'e', |
| 3583 | 'E', |
| 3584 | 'e', |
| 3585 | 'E', |
| 3586 | 'e', |
| 3587 | 'E', |
| 3588 | 'e', |
| 3589 | 'E', |
| 3590 | 'e', |
| 3591 | 'G', |
| 3592 | 'g', |
| 3593 | 'G', |
| 3594 | 'g', |
| 3595 | 'G', |
| 3596 | 'g', |
| 3597 | 'G', |
| 3598 | 'g', |
| 3599 | 'H', |
| 3600 | 'h', |
| 3601 | 'H', |
| 3602 | 'h', |
| 3603 | 'I', |
| 3604 | 'i', |
| 3605 | 'I', |
| 3606 | 'i', |
| 3607 | 'I', |
| 3608 | 'i', |
| 3609 | 'I', |
| 3610 | 'i', |
| 3611 | 'I', |
| 3612 | 'i', |
| 3613 | '?', |
| 3614 | '?', |
| 3615 | 'J', |
| 3616 | 'j', |
| 3617 | 'K', |
| 3618 | 'k', |
| 3619 | 'L', |
| 3620 | 'l', |
| 3621 | 'L', |
| 3622 | 'l', |
| 3623 | 'L', |
| 3624 | 'l', |
| 3625 | '?', |
| 3626 | '?', |
| 3627 | 'L', |
| 3628 | 'l', |
| 3629 | 'N', |
| 3630 | 'n', |
| 3631 | 'N', |
| 3632 | 'n', |
| 3633 | 'N', |
| 3634 | 'n', |
| 3635 | '?', |
| 3636 | 'O', |
| 3637 | 'o', |
| 3638 | 'O', |
| 3639 | 'o', |
| 3640 | 'O', |
| 3641 | 'o', |
| 3642 | 'Œ', |
| 3643 | 'œ', |
| 3644 | 'R', |
| 3645 | 'r', |
| 3646 | 'R', |
| 3647 | 'r', |
| 3648 | 'R', |
| 3649 | 'r', |
| 3650 | 'S', |
| 3651 | 's', |
| 3652 | 'S', |
| 3653 | 's', |
| 3654 | 'S', |
| 3655 | 's', |
| 3656 | 'Š', |
| 3657 | 'š', |
| 3658 | 'T', |
| 3659 | 't', |
| 3660 | 'T', |
| 3661 | 't', |
| 3662 | 'T', |
| 3663 | 't', |
| 3664 | 'U', |
| 3665 | 'u', |
| 3666 | 'U', |
| 3667 | 'u', |
| 3668 | 'U', |
| 3669 | 'u', |
| 3670 | 'U', |
| 3671 | 'u', |
| 3672 | 'U', |
| 3673 | 'u', |
| 3674 | 'U', |
| 3675 | 'u', |
| 3676 | 'W', |
| 3677 | 'w', |
| 3678 | 'Y', |
| 3679 | 'y', |
| 3680 | 'Ÿ', |
| 3681 | 'Z', |
| 3682 | 'z', |
| 3683 | 'Z', |
| 3684 | 'z', |
| 3685 | 'Ž', |
| 3686 | 'ž', |
| 3687 | '?', |
| 3688 | 'ƒ', |
| 3689 | 'O', |
| 3690 | 'o', |
| 3691 | 'U', |
| 3692 | 'u', |
| 3693 | 'A', |
| 3694 | 'a', |
| 3695 | 'I', |
| 3696 | 'i', |
| 3697 | 'O', |
| 3698 | 'o', |
| 3699 | 'U', |
| 3700 | 'u', |
| 3701 | 'U', |
| 3702 | 'u', |
| 3703 | 'U', |
| 3704 | 'u', |
| 3705 | 'U', |
| 3706 | 'u', |
| 3707 | 'U', |
| 3708 | 'u', |
| 3709 | '?', |
| 3710 | '?', |
| 3711 | '?', |
| 3712 | '?', |
| 3713 | '?', |
| 3714 | '?', |
| 3715 | ]; |
| 3716 | $b = [ |
| 3717 | 'A', |
| 3718 | 'A', |
| 3719 | 'A', |
| 3720 | 'A', |
| 3721 | 'A', |
| 3722 | 'A', |
| 3723 | 'AE', |
| 3724 | 'C', |
| 3725 | 'E', |
| 3726 | 'E', |
| 3727 | 'E', |
| 3728 | 'E', |
| 3729 | 'I', |
| 3730 | 'I', |
| 3731 | 'I', |
| 3732 | 'I', |
| 3733 | 'D', |
| 3734 | 'N', |
| 3735 | 'O', |
| 3736 | 'O', |
| 3737 | 'O', |
| 3738 | 'O', |
| 3739 | 'O', |
| 3740 | 'O', |
| 3741 | 'U', |
| 3742 | 'U', |
| 3743 | 'U', |
| 3744 | 'U', |
| 3745 | 'Y', |
| 3746 | 's', |
| 3747 | 'a', |
| 3748 | 'a', |
| 3749 | 'a', |
| 3750 | 'a', |
| 3751 | 'a', |
| 3752 | 'a', |
| 3753 | 'ae', |
| 3754 | 'c', |
| 3755 | 'e', |
| 3756 | 'e', |
| 3757 | 'e', |
| 3758 | 'e', |
| 3759 | 'i', |
| 3760 | 'i', |
| 3761 | 'i', |
| 3762 | 'i', |
| 3763 | 'n', |
| 3764 | 'o', |
| 3765 | 'o', |
| 3766 | 'o', |
| 3767 | 'o', |
| 3768 | 'o', |
| 3769 | 'o', |
| 3770 | 'u', |
| 3771 | 'u', |
| 3772 | 'u', |
| 3773 | 'u', |
| 3774 | 'y', |
| 3775 | 'y', |
| 3776 | 'A', |
| 3777 | 'a', |
| 3778 | 'A', |
| 3779 | 'a', |
| 3780 | 'A', |
| 3781 | 'a', |
| 3782 | 'C', |
| 3783 | 'c', |
| 3784 | 'C', |
| 3785 | 'c', |
| 3786 | 'C', |
| 3787 | 'c', |
| 3788 | 'C', |
| 3789 | 'c', |
| 3790 | 'D', |
| 3791 | 'd', |
| 3792 | 'D', |
| 3793 | 'd', |
| 3794 | 'E', |
| 3795 | 'e', |
| 3796 | 'E', |
| 3797 | 'e', |
| 3798 | 'E', |
| 3799 | 'e', |
| 3800 | 'E', |
| 3801 | 'e', |
| 3802 | 'E', |
| 3803 | 'e', |
| 3804 | 'G', |
| 3805 | 'g', |
| 3806 | 'G', |
| 3807 | 'g', |
| 3808 | 'G', |
| 3809 | 'g', |
| 3810 | 'G', |
| 3811 | 'g', |
| 3812 | 'H', |
| 3813 | 'h', |
| 3814 | 'H', |
| 3815 | 'h', |
| 3816 | 'I', |
| 3817 | 'i', |
| 3818 | 'I', |
| 3819 | 'i', |
| 3820 | 'I', |
| 3821 | 'i', |
| 3822 | 'I', |
| 3823 | 'i', |
| 3824 | 'I', |
| 3825 | 'i', |
| 3826 | 'IJ', |
| 3827 | 'ij', |
| 3828 | 'J', |
| 3829 | 'j', |
| 3830 | 'K', |
| 3831 | 'k', |
| 3832 | 'L', |
| 3833 | 'l', |
| 3834 | 'L', |
| 3835 | 'l', |
| 3836 | 'L', |
| 3837 | 'l', |
| 3838 | 'L', |
| 3839 | 'l', |
| 3840 | 'l', |
| 3841 | 'l', |
| 3842 | 'N', |
| 3843 | 'n', |
| 3844 | 'N', |
| 3845 | 'n', |
| 3846 | 'N', |
| 3847 | 'n', |
| 3848 | 'n', |
| 3849 | 'O', |
| 3850 | 'o', |
| 3851 | 'O', |
| 3852 | 'o', |
| 3853 | 'O', |
| 3854 | 'o', |
| 3855 | 'OE', |
| 3856 | 'oe', |
| 3857 | 'R', |
| 3858 | 'r', |
| 3859 | 'R', |
| 3860 | 'r', |
| 3861 | 'R', |
| 3862 | 'r', |
| 3863 | 'S', |
| 3864 | 's', |
| 3865 | 'S', |
| 3866 | 's', |
| 3867 | 'S', |
| 3868 | 's', |
| 3869 | 'S', |
| 3870 | 's', |
| 3871 | 'T', |
| 3872 | 't', |
| 3873 | 'T', |
| 3874 | 't', |
| 3875 | 'T', |
| 3876 | 't', |
| 3877 | 'U', |
| 3878 | 'u', |
| 3879 | 'U', |
| 3880 | 'u', |
| 3881 | 'U', |
| 3882 | 'u', |
| 3883 | 'U', |
| 3884 | 'u', |
| 3885 | 'U', |
| 3886 | 'u', |
| 3887 | 'U', |
| 3888 | 'u', |
| 3889 | 'W', |
| 3890 | 'w', |
| 3891 | 'Y', |
| 3892 | 'y', |
| 3893 | 'Y', |
| 3894 | 'Z', |
| 3895 | 'z', |
| 3896 | 'Z', |
| 3897 | 'z', |
| 3898 | 'Z', |
| 3899 | 'z', |
| 3900 | 's', |
| 3901 | 'f', |
| 3902 | 'O', |
| 3903 | 'o', |
| 3904 | 'U', |
| 3905 | 'u', |
| 3906 | 'A', |
| 3907 | 'a', |
| 3908 | 'I', |
| 3909 | 'i', |
| 3910 | 'O', |
| 3911 | 'o', |
| 3912 | 'U', |
| 3913 | 'u', |
| 3914 | 'U', |
| 3915 | 'u', |
| 3916 | 'U', |
| 3917 | 'u', |
| 3918 | 'U', |
| 3919 | 'u', |
| 3920 | 'U', |
| 3921 | 'u', |
| 3922 | 'A', |
| 3923 | 'a', |
| 3924 | 'AE', |
| 3925 | 'ae', |
| 3926 | 'O', |
| 3927 | 'o', |
| 3928 | ]; |
| 3929 | return strtolower(preg_replace(['/[^a-zA-Z0-9 -]/', '/[ -]+/', '/^-|-$/'], ['', '-', ''], str_replace($a, $b, $str))); |
| 3930 | |
| 3931 | }//end create_slug_from_string() |
| 3932 | |
| 3933 | |
| 3934 | /** |
| 3935 | * Sanitize input options |
| 3936 | * |
| 3937 | * @since 1.0.0 |
| 3938 | * @access public |
| 3939 | * @return $value |
| 3940 | */ |
| 3941 | public static function sanitize_options($value, $type="") |
| 3942 | { |
| 3943 | $value = stripslashes($value); |
| 3944 | if ($type == "int") { |
| 3945 | $value = filter_var($value, FILTER_SANITIZE_NUMBER_INT); |
| 3946 | } else if ($type == "email") { |
| 3947 | $value = filter_var($value, FILTER_SANITIZE_EMAIL); |
| 3948 | } else { |
| 3949 | $value = sanitize_text_field($value); |
| 3950 | } |
| 3951 | |
| 3952 | return $value; |
| 3953 | |
| 3954 | }//end sanitize_options() |
| 3955 | |
| 3956 | |
| 3957 | /** |
| 3958 | * Add new folder |
| 3959 | * |
| 3960 | * @since 1.0.0 |
| 3961 | * @access public |
| 3962 | * @return $response |
| 3963 | */ |
| 3964 | public function wcp_add_new_folder() |
| 3965 | { |
| 3966 | $response = []; |
| 3967 | $response['status'] = 0; |
| 3968 | $response['error'] = 0; |
| 3969 | $response['login'] = 1; |
| 3970 | $response['data'] = []; |
| 3971 | $response['message'] = ""; |
| 3972 | $response['message2'] = ""; |
| 3973 | $postData = filter_input_array(INPUT_POST); |
| 3974 | $errorCounter = 0; |
| 3975 | $error = ""; |
| 3976 | if (!current_user_can("manage_categories")) { |
| 3977 | $error = esc_html__("You have not permission to add folder", 'folders'); |
| 3978 | $errorCounter++; |
| 3979 | } else if (!isset($postData['name']) || empty($postData['name'])) { |
| 3980 | $error = esc_html__("Folder name can no be empty", 'folders'); |
| 3981 | $errorCounter++; |
| 3982 | } else if (!isset($postData['type']) || empty($postData['type'])) { |
| 3983 | $error = esc_html__("Your request is not valid", 'folders'); |
| 3984 | $errorCounter++; |
| 3985 | } else if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 3986 | $response['login'] = 0; |
| 3987 | $error = esc_html__("Unable to create folder, Your request is not valid", 'folders'); |
| 3988 | $errorCounter++; |
| 3989 | } else { |
| 3990 | $type = self::sanitize_options($postData['type']); |
| 3991 | if (!wp_verify_nonce($postData['nonce'], 'wcp_folder_nonce_'.$type)) { |
| 3992 | $response['login'] = 0; |
| 3993 | $error = esc_html__("Unable to create folder, Your request is not valid", 'folders'); |
| 3994 | $errorCounter++; |
| 3995 | } |
| 3996 | }//end if |
| 3997 | |
| 3998 | if ($errorCounter == 0) { |
| 3999 | $parent = isset($postData['parent_id']) && !empty($postData['parent_id']) ? $postData['parent_id'] : 0; |
| 4000 | $parent_menu = isset($postData['parent_menu']) && !empty($postData['parent_menu']) ? $postData['parent_menu'] : 0; |
| 4001 | $parent_ids = isset($postData['parent_ids']) && !empty($postData['parent_ids']) ? $postData['parent_ids'] : 0; |
| 4002 | $parent = self::sanitize_options($parent); |
| 4003 | $type = self::sanitize_options($postData['type']); |
| 4004 | $folder_type = self::get_custom_post_type($type); |
| 4005 | $term_name = self::sanitize_options($postData['name']); |
| 4006 | $term = term_exists($term_name, $folder_type, $parent); |
| 4007 | $term_id = 0; |
| 4008 | if (!(0 !== $term && null !== $term)) { |
| 4009 | $folders = $postData['name']; |
| 4010 | $folders = explode(",", $folders); |
| 4011 | $foldersArray = []; |
| 4012 | $order = isset($postData['order']) ? $postData['order'] : 0; |
| 4013 | $order = self::sanitize_options($order); |
| 4014 | |
| 4015 | $is_active = 1; |
| 4016 | $total_folders = -1; |
| 4017 | |
| 4018 | if (!$is_active) { |
| 4019 | if (($total_folders + count($folders)) > 10) { |
| 4020 | $response['status'] = -1; |
| 4021 | echo json_encode($response); |
| 4022 | wp_die(); |
| 4023 | } |
| 4024 | } |
| 4025 | |
| 4026 | foreach ($folders as $key => $folder) { |
| 4027 | $folder = trim($folder); |
| 4028 | $slug = self::create_slug_from_string($folder)."-".time(); |
| 4029 | |
| 4030 | $result = wp_insert_term( |
| 4031 | urldecode($folder), |
| 4032 | // the term |
| 4033 | $folder_type, |
| 4034 | // the taxonomy |
| 4035 | [ |
| 4036 | 'parent' => $parent, |
| 4037 | 'slug' => $slug, |
| 4038 | ] |
| 4039 | ); |
| 4040 | if (!empty($result)) { |
| 4041 | $term_id = $result['term_id']; |
| 4042 | $total_folders++; |
| 4043 | $response['id'] = $result['term_id']; |
| 4044 | $response['status'] = 1; |
| 4045 | $term = get_term($result['term_id'], $folder_type); |
| 4046 | $order = ($order + $key); |
| 4047 | $term_nonce = wp_create_nonce('wcp_folder_term_'.$term->term_id); |
| 4048 | |
| 4049 | $folder_item = []; |
| 4050 | $folder_item['parent_id'] = $parent; |
| 4051 | $folder_item['slug'] = $term->slug; |
| 4052 | $folder_item['nonce'] = $term_nonce; |
| 4053 | $folder_item['term_id'] = $result['term_id']; |
| 4054 | $folder_item['title'] = $folder; |
| 4055 | $folder_item['parent_id'] = empty($postData['parent_id']) ? "0" : $postData['parent_id']; |
| 4056 | $folder_item['is_sticky'] = 0; |
| 4057 | $folder_item['is_high'] = 0; |
| 4058 | |
| 4059 | update_term_meta($result['term_id'], "wcp_custom_order", $order); |
| 4060 | if ($parent != 0) { |
| 4061 | update_term_meta($parent, "is_active", 1); |
| 4062 | } |
| 4063 | |
| 4064 | if (isset($postData['is_duplicate']) && $postData['is_duplicate'] == true) { |
| 4065 | if (isset($postData['duplicate_from']) && !empty($postData['duplicate_from'])) { |
| 4066 | $term_id = $postData['duplicate_from']; |
| 4067 | |
| 4068 | $term_data = get_term($term_id, $folder_type); |
| 4069 | if (!empty($term_data)) { |
| 4070 | $is_sticky = get_term_meta($term_id, "is_folder_sticky", true); |
| 4071 | |
| 4072 | if ($is_sticky == 1) { |
| 4073 | add_term_meta($term->term_id, "is_folder_sticky", 1); |
| 4074 | $folder_item['is_sticky'] = 1; |
| 4075 | } |
| 4076 | |
| 4077 | $status = get_term_meta($term_id, "is_highlighted", true); |
| 4078 | if ($status == 1) { |
| 4079 | add_term_meta($term->term_id, "is_highlighted", 1); |
| 4080 | $folder_item['is_high'] = 1; |
| 4081 | } |
| 4082 | |
| 4083 | $postArray = get_posts( |
| 4084 | [ |
| 4085 | 'posts_per_page' => -1, |
| 4086 | 'post_type' => $type, |
| 4087 | 'tax_query' => [ |
| 4088 | [ |
| 4089 | 'taxonomy' => $folder_type, |
| 4090 | 'field' => 'term_id', |
| 4091 | 'terms' => $term_id, |
| 4092 | ], |
| 4093 | ], |
| 4094 | ] |
| 4095 | ); |
| 4096 | if (!empty($postArray)) { |
| 4097 | foreach ($postArray as $p) { |
| 4098 | wp_set_post_terms($p->ID, $term->term_id, $folder_type, true); |
| 4099 | } |
| 4100 | } |
| 4101 | }//end if |
| 4102 | }//end if |
| 4103 | }//end if |
| 4104 | |
| 4105 | if ($parent_menu && !empty($parent_ids)) { |
| 4106 | $order = isset($postData['order']) ? $postData['order'] : 0; |
| 4107 | $parent_ids = trim($parent_ids, ","); |
| 4108 | $parent_ids = explode(",", $parent_ids); |
| 4109 | $folder_order = 0; |
| 4110 | $parents = ""; |
| 4111 | if (is_array($parent_ids) && count($parent_ids) > 0) { |
| 4112 | foreach ($parent_ids as $key => $value) { |
| 4113 | if ($value != "#") { |
| 4114 | delete_term_meta($value, "wcp_custom_order"); |
| 4115 | add_term_meta($value, "wcp_custom_order", $folder_order); |
| 4116 | } else if (!empty($term_id)) { |
| 4117 | delete_term_meta($term_id, "wcp_custom_order"); |
| 4118 | add_term_meta($term_id, "wcp_custom_order", $folder_order); |
| 4119 | } |
| 4120 | |
| 4121 | $folder_order++; |
| 4122 | } |
| 4123 | } |
| 4124 | } |
| 4125 | |
| 4126 | $foldersArray[] = $folder_item; |
| 4127 | }//end if |
| 4128 | |
| 4129 | if (!empty($foldersArray)) { |
| 4130 | $response['is_key_active'] = $is_active; |
| 4131 | $response['folders'] = $total_folders; |
| 4132 | $response['parent_id'] = empty($parent) ? "#" : $parent; |
| 4133 | |
| 4134 | $response['status'] = 1; |
| 4135 | $response['data'] = $foldersArray; |
| 4136 | } |
| 4137 | }//end foreach |
| 4138 | } else { |
| 4139 | $response['error'] = 1; |
| 4140 | $response['message'] = esc_html__("Folder name already exists", 'folders'); |
| 4141 | }//end if |
| 4142 | } else { |
| 4143 | $response['error'] = 1; |
| 4144 | $response['message'] = $error; |
| 4145 | }//end if |
| 4146 | |
| 4147 | echo json_encode($response); |
| 4148 | wp_die(); |
| 4149 | |
| 4150 | }//end wcp_add_new_folder() |
| 4151 | |
| 4152 | |
| 4153 | /** |
| 4154 | * Check is folder active for post, page, attachment |
| 4155 | * |
| 4156 | * @since 1.0.0 |
| 4157 | * @access public |
| 4158 | * @return $post_type |
| 4159 | */ |
| 4160 | public function is_for_this_post_type($post_type) |
| 4161 | { |
| 4162 | $post_types = get_option('folders_settings'); |
| 4163 | $post_types = is_array($post_types) ? $post_types : []; |
| 4164 | return in_array($post_type, $post_types); |
| 4165 | |
| 4166 | }//end is_for_this_post_type() |
| 4167 | |
| 4168 | |
| 4169 | /** |
| 4170 | * Check is folder active for current screen |
| 4171 | * |
| 4172 | * @since 1.0.0 |
| 4173 | * @access public |
| 4174 | * @return $status |
| 4175 | */ |
| 4176 | public function is_active_for_screen() |
| 4177 | { |
| 4178 | global $typenow, $current_screen; |
| 4179 | |
| 4180 | $postData = filter_input_array(INPUT_POST); |
| 4181 | |
| 4182 | global $current_screen; |
| 4183 | |
| 4184 | if (self::is_for_this_post_type($typenow) && ('edit' == $current_screen->base || 'upload' == $current_screen->base)) { |
| 4185 | return true; |
| 4186 | } |
| 4187 | |
| 4188 | $post_types = get_option('folders_settings'); |
| 4189 | $post_types = is_array($post_types) ? $post_types : []; |
| 4190 | |
| 4191 | if (empty($typenow) && (isset($current_screen->base) && 'upload' == $current_screen->base)) { |
| 4192 | $typenow = "attachment"; |
| 4193 | if (self::is_for_this_post_type($typenow)) { |
| 4194 | return true; |
| 4195 | } |
| 4196 | } |
| 4197 | |
| 4198 | return false; |
| 4199 | |
| 4200 | }//end is_active_for_screen() |
| 4201 | |
| 4202 | |
| 4203 | /** |
| 4204 | * Check is post update screen |
| 4205 | * |
| 4206 | * @since 1.0.0 |
| 4207 | * @access public |
| 4208 | * @return $status |
| 4209 | */ |
| 4210 | public function is_add_update_screen() |
| 4211 | { |
| 4212 | global $current_screen; |
| 4213 | $current_type = $current_screen->base; |
| 4214 | $action = $current_screen->action; |
| 4215 | $post_types = get_option('folders_settings'); |
| 4216 | $post_types = is_array($post_types) ? $post_types : []; |
| 4217 | global $typenow; |
| 4218 | if (in_array($current_type, $post_types) && in_array($action, ["add", ""])) { |
| 4219 | $license_data = self::get_license_key_data(); |
| 4220 | |
| 4221 | $is_active = 1; |
| 4222 | $folders = -1; |
| 4223 | $response['folders'] = $folders; |
| 4224 | $response['is_key_active'] = $is_active; |
| 4225 | } |
| 4226 | |
| 4227 | }//end is_add_update_screen() |
| 4228 | |
| 4229 | |
| 4230 | /** |
| 4231 | * Get folder type for page, post, attachment |
| 4232 | * |
| 4233 | * @since 1.0.0 |
| 4234 | * @access public |
| 4235 | * @return $status |
| 4236 | */ |
| 4237 | public static function get_custom_post_type($post_type) |
| 4238 | { |
| 4239 | if ($post_type == "post") { |
| 4240 | return "post_folder"; |
| 4241 | } else if ($post_type == "page") { |
| 4242 | return "folder"; |
| 4243 | } else if ($post_type == "attachment") { |
| 4244 | return "media_folder"; |
| 4245 | } |
| 4246 | |
| 4247 | return $post_type.'_folder'; |
| 4248 | |
| 4249 | }//end get_custom_post_type() |
| 4250 | |
| 4251 | |
| 4252 | /** |
| 4253 | * Add folders data to footer |
| 4254 | * |
| 4255 | * @since 1.0.0 |
| 4256 | * @access public |
| 4257 | * @return $html |
| 4258 | */ |
| 4259 | public function admin_footer() |
| 4260 | { |
| 4261 | if (self::is_active_for_screen()) { |
| 4262 | global $typenow; |
| 4263 | |
| 4264 | self::set_default_values_if_not_exists(); |
| 4265 | |
| 4266 | $ttpsts = self::get_ttlpst($typenow); |
| 4267 | |
| 4268 | $ttemp = self::get_tempt_posts($typenow); |
| 4269 | |
| 4270 | $folder_type = self::get_custom_post_type($typenow); |
| 4271 | // Do not change: Free/Pro Class name change |
| 4272 | $tree_data = WCP_Tree::get_full_tree_data($folder_type); |
| 4273 | $terms_data = $tree_data['string']; |
| 4274 | $sticky_string = $tree_data['sticky_string']; |
| 4275 | $terms_html = WCP_Tree::get_option_data_for_select($folder_type); |
| 4276 | $form_html = WCP_Forms::get_form_html($terms_html); |
| 4277 | include_once dirname(dirname(__FILE__)).WCP_DS."/templates".WCP_DS."admin".WCP_DS."admin-content.php"; |
| 4278 | } |
| 4279 | |
| 4280 | global $pagenow; |
| 4281 | if ('plugins.php' !== $pagenow) { |
| 4282 | } else { |
| 4283 | if (current_user_can('manage_options')) { |
| 4284 | include_once dirname(dirname(__FILE__)).WCP_DS."/templates".WCP_DS."admin".WCP_DS."folder-deactivate-form.php"; |
| 4285 | } |
| 4286 | } |
| 4287 | |
| 4288 | }//end admin_footer() |
| 4289 | |
| 4290 | |
| 4291 | /** |
| 4292 | * Get total posts |
| 4293 | * |
| 4294 | * @since 1.0.0 |
| 4295 | * @access public |
| 4296 | * @return $item_count |
| 4297 | */ |
| 4298 | public function get_ttlpst($post_type="") |
| 4299 | { |
| 4300 | global $typenow; |
| 4301 | if (empty($post_type)) { |
| 4302 | $post_type = $typenow; |
| 4303 | } |
| 4304 | $item_count = null; |
| 4305 | if(has_filter("premio_folder_all_categorized_items")) { |
| 4306 | $item_count = apply_filters("premio_folder_all_categorized_items", $post_type); |
| 4307 | } |
| 4308 | if($item_count === null) { |
| 4309 | if ($post_type == "attachment") { |
| 4310 | $item_count = wp_count_posts($post_type)->inherit; |
| 4311 | } else { |
| 4312 | $item_count = wp_count_posts($post_type)->publish + wp_count_posts($post_type)->draft + wp_count_posts($post_type)->future + wp_count_posts($post_type)->private + wp_count_posts($post_type)->pending; |
| 4313 | } |
| 4314 | } |
| 4315 | return $item_count; |
| 4316 | }//end get_ttlpst() |
| 4317 | |
| 4318 | |
| 4319 | /** |
| 4320 | * Autoload folders librarires |
| 4321 | * |
| 4322 | * @since 1.0.0 |
| 4323 | * @access public |
| 4324 | * @return $files |
| 4325 | */ |
| 4326 | public function autoload() |
| 4327 | { |
| 4328 | $files = [ |
| 4329 | 'WCP_Tree_View' => WCP_DS."includes".WCP_DS."tree.class.php", |
| 4330 | 'WCP_Form_View' => WCP_DS."includes".WCP_DS."form.class.php", |
| 4331 | 'WCP_Folder_WPML' => WCP_DS."includes".WCP_DS."class-wpml.php", |
| 4332 | 'WCP_Folder_PolyLang' => WCP_DS."includes".WCP_DS."class-polylang.php", |
| 4333 | ]; |
| 4334 | |
| 4335 | foreach ($files as $file) { |
| 4336 | if (file_exists(dirname(dirname(__FILE__)).$file)) { |
| 4337 | include_once dirname(dirname(__FILE__)).$file; |
| 4338 | } |
| 4339 | } |
| 4340 | |
| 4341 | }//end autoload() |
| 4342 | |
| 4343 | |
| 4344 | /** |
| 4345 | * Create folder taxonomies |
| 4346 | * |
| 4347 | * @since 1.0.0 |
| 4348 | * @access public |
| 4349 | * @return $taxonomies |
| 4350 | */ |
| 4351 | public function create_folder_terms() |
| 4352 | { |
| 4353 | $options = get_option('folders_settings'); |
| 4354 | $options = is_array($options) ? $options : []; |
| 4355 | $old_plugin_status = 0; |
| 4356 | $posts = []; |
| 4357 | if (!empty($options)) { |
| 4358 | foreach ($options as $option) { |
| 4359 | if (!(strpos($option, 'folder4') === false) && $old_plugin_status == 0) { |
| 4360 | $old_plugin_status = 1; |
| 4361 | } |
| 4362 | |
| 4363 | if (in_array($option, ["page", "post", "attachment"])) { |
| 4364 | $posts[] = str_replace("folder4", "", $option); |
| 4365 | } else { |
| 4366 | $posts[] = $option; |
| 4367 | } |
| 4368 | } |
| 4369 | |
| 4370 | if (!empty($posts)) { |
| 4371 | update_option('folders_settings', $posts); |
| 4372 | } |
| 4373 | } |
| 4374 | |
| 4375 | if ($old_plugin_status == 1) { |
| 4376 | update_option("folders_show_in_menu", "on"); |
| 4377 | $old_plugin_var = get_option("folder_old_plugin_status"); |
| 4378 | if (empty($old_plugin_var) || $old_plugin_var == null) { |
| 4379 | update_option("folder_old_plugin_status", "1"); |
| 4380 | } |
| 4381 | } |
| 4382 | |
| 4383 | $posts = get_option('folders_settings'); |
| 4384 | if (!empty($posts)) { |
| 4385 | foreach ($posts as $post_type) { |
| 4386 | $labels = [ |
| 4387 | 'name' => esc_html__('Folders', 'folders'), |
| 4388 | 'singular_name' => esc_html__('Folder', 'folders'), |
| 4389 | 'all_items' => esc_html__('All Folders', 'folders'), |
| 4390 | 'edit_item' => esc_html__('Edit Folder', 'folders'), |
| 4391 | 'update_item' => esc_html__('Update Folder', 'folders'), |
| 4392 | 'add_new_item' => esc_html__('Add New Folder', 'folders'), |
| 4393 | 'new_item_name' => esc_html__('Add folder name', 'folders'), |
| 4394 | 'menu_name' => esc_html__('Folders', 'folders'), |
| 4395 | 'search_items' => esc_html__('Search Folders', 'folders'), |
| 4396 | 'parent_item' => esc_html__('Parent Folder', 'folders'), |
| 4397 | ]; |
| 4398 | |
| 4399 | $args = [ |
| 4400 | 'label' => esc_html__('Folder', 'folders'), |
| 4401 | 'labels' => $labels, |
| 4402 | 'show_tagcloud' => false, |
| 4403 | 'hierarchical' => true, |
| 4404 | 'public' => false, |
| 4405 | 'show_ui' => true, |
| 4406 | 'show_in_menu' => false, |
| 4407 | 'show_in_rest' => true, |
| 4408 | 'show_admin_column' => true, |
| 4409 | 'update_count_callback' => '_update_post_term_count', |
| 4410 | // 'update_count_callback' => '_update_generic_term_count', |
| 4411 | 'query_var' => true, |
| 4412 | 'rewrite' => false, |
| 4413 | 'capabilities' => [ |
| 4414 | 'manage_terms' => 'manage_categories', |
| 4415 | 'edit_terms' => 'manage_categories', |
| 4416 | 'delete_terms' => 'manage_categories', |
| 4417 | 'assign_terms' => 'manage_categories', |
| 4418 | ], |
| 4419 | ]; |
| 4420 | |
| 4421 | $folder_post_type = self::get_custom_post_type($post_type); |
| 4422 | |
| 4423 | register_taxonomy( |
| 4424 | $folder_post_type, |
| 4425 | $post_type, |
| 4426 | $args |
| 4427 | ); |
| 4428 | }//end foreach |
| 4429 | }//end if |
| 4430 | |
| 4431 | $postData = filter_input_array(INPUT_POST); |
| 4432 | |
| 4433 | if (current_user_can("manage_categories") && isset($postData['folder_nonce'])) { |
| 4434 | if (wp_verify_nonce($postData['folder_nonce'], "folder_settings")) { |
| 4435 | if (isset($postData['folders_show_in_menu']) && !empty($postData['folders_show_in_menu'])) { |
| 4436 | $show_menu = "off"; |
| 4437 | if ($postData['folders_show_in_menu'] == "on") { |
| 4438 | $show_menu = "on"; |
| 4439 | } |
| 4440 | |
| 4441 | update_option("folders_show_in_menu", $show_menu); |
| 4442 | } |
| 4443 | |
| 4444 | if (isset($postData['folders_settings1'])) { |
| 4445 | $posts = []; |
| 4446 | if (isset($postData['folders_settings']) && is_array($postData['folders_settings'])) { |
| 4447 | foreach ($postData['folders_settings'] as $key => $val) { |
| 4448 | $posts[] = $val; |
| 4449 | } |
| 4450 | } |
| 4451 | |
| 4452 | update_option("folders_settings", $posts); |
| 4453 | } |
| 4454 | |
| 4455 | $postData = filter_input_array(INPUT_POST); |
| 4456 | |
| 4457 | if (isset($postData['folders_settings1'])) { |
| 4458 | $posts = []; |
| 4459 | if (isset($postData['default_folders']) && is_array($postData['default_folders'])) { |
| 4460 | foreach ($postData['default_folders'] as $key => $val) { |
| 4461 | $posts[$key] = $val; |
| 4462 | } |
| 4463 | } |
| 4464 | |
| 4465 | update_option("default_folders", $posts); |
| 4466 | } |
| 4467 | |
| 4468 | if (isset($postData['customize_folders'])) { |
| 4469 | $posts = []; |
| 4470 | if (isset($postData['customize_folders']) && is_array($postData['customize_folders'])) { |
| 4471 | foreach ($postData['customize_folders'] as $key => $val) { |
| 4472 | $posts[$key] = $val; |
| 4473 | } |
| 4474 | } |
| 4475 | |
| 4476 | update_option("customize_folders", $posts); |
| 4477 | } |
| 4478 | |
| 4479 | $setting_page = $this->getFolderSettingsURL(); |
| 4480 | if (!empty($setting_page)) { |
| 4481 | $page = filter_input(INPUT_POST, 'tab_page'); |
| 4482 | $type = filter_input(INPUT_GET, 'setting_page'); |
| 4483 | $type = empty($type) ? "" : "&setting_page=".esc_attr($type); |
| 4484 | $setting_page = $setting_page.$type; |
| 4485 | if (!empty($page)) { |
| 4486 | $setting_page .= "&setting_page=".esc_attr($page); |
| 4487 | } |
| 4488 | |
| 4489 | wp_redirect($setting_page."¬e=1"); |
| 4490 | exit; |
| 4491 | } else { |
| 4492 | $folder_page = filter_input(INPUT_POST, 'folder_page'); |
| 4493 | if (!empty($folder_page)) { |
| 4494 | wp_redirect($folder_page); |
| 4495 | exit; |
| 4496 | } |
| 4497 | } |
| 4498 | }//end if |
| 4499 | }//end if |
| 4500 | |
| 4501 | // $old_version = get_option("folder_old_plugin_status"); |
| 4502 | // if($old_version !== false && $old_version == 1) { |
| 4503 | // $tlfs = get_option("folder_old_plugin_folder_status"); |
| 4504 | // if($tlfs === false) { |
| 4505 | // $total = self::ttl_fldrs(); |
| 4506 | // if($total <= 10) { |
| 4507 | // $total = 10; |
| 4508 | // }; |
| 4509 | // update_option("folder_old_plugin_folder_status", $total); |
| 4510 | // self::$folders = $total; |
| 4511 | // } else { |
| 4512 | // self::$folders = $tlfs; |
| 4513 | // } |
| 4514 | // } |
| 4515 | // |
| 4516 | // $tlfs = get_option("folder_old_plugin_folder_status"); |
| 4517 | // if($tlfs === false) { |
| 4518 | // self::$folders = 10; |
| 4519 | // } else { |
| 4520 | // self::$folders = $tlfs; |
| 4521 | // } |
| 4522 | |
| 4523 | }//end create_folder_terms() |
| 4524 | |
| 4525 | |
| 4526 | /** |
| 4527 | * Search for data from list |
| 4528 | * |
| 4529 | * @since 1.0.0 |
| 4530 | * @access public |
| 4531 | * @return $key |
| 4532 | */ |
| 4533 | function searchForId($id, $menu) |
| 4534 | { |
| 4535 | if ($menu) { |
| 4536 | foreach ($menu as $key => $val) { |
| 4537 | if (array_key_exists(2, $val)) { |
| 4538 | $stripVal = explode('=', $val[2]); |
| 4539 | } |
| 4540 | |
| 4541 | if (array_key_exists(1, $stripVal)) { |
| 4542 | $stripVal = $stripVal[1]; |
| 4543 | } |
| 4544 | |
| 4545 | if ($stripVal === $id) { |
| 4546 | return $key; |
| 4547 | } |
| 4548 | } |
| 4549 | } |
| 4550 | |
| 4551 | }//end searchForId() |
| 4552 | |
| 4553 | |
| 4554 | /** |
| 4555 | * Create setting menu for folders |
| 4556 | * |
| 4557 | * @since 1.0.0 |
| 4558 | * @access public |
| 4559 | */ |
| 4560 | function create_menu_for_folders() |
| 4561 | { |
| 4562 | global $menu; |
| 4563 | self::check_and_set_post_type(); |
| 4564 | |
| 4565 | $folder_types = get_option("folders_settings"); |
| 4566 | if (empty($folder_types)) { |
| 4567 | return; |
| 4568 | } |
| 4569 | |
| 4570 | foreach ($folder_types as $type) { |
| 4571 | $itemKey = self::searchForId($type, $menu); |
| 4572 | switch (true) { |
| 4573 | case ($type == 'attachment'): |
| 4574 | $itemKey = 10; |
| 4575 | $edit = 'upload.php'; |
| 4576 | break; |
| 4577 | case ($type === 'post'): |
| 4578 | $edit = 'edit.php'; |
| 4579 | $itemKey = 5; |
| 4580 | break; |
| 4581 | default: |
| 4582 | $edit = 'edit.php'; |
| 4583 | break; |
| 4584 | } |
| 4585 | |
| 4586 | $folder = $type == 'attachment' ? 'media' : $type; |
| 4587 | $upper = $type == 'attachment' ? 'Media' : ucwords(str_replace(['-', '_'], ' ', $type)); |
| 4588 | if ($type == 'page') { |
| 4589 | $tax_slug = 'folder'; |
| 4590 | } else { |
| 4591 | $tax_slug = $folder.'_folder'; |
| 4592 | } |
| 4593 | |
| 4594 | $hide_empty = true; |
| 4595 | if ($type == 'attachment') { |
| 4596 | $hide_empty = false; |
| 4597 | add_menu_page('Media Folders', 'Media Folders', 'publish_pages', "{$edit}?post_type=attachment&media_folder=", false, 'dashicons-portfolio', "{$itemKey}.5"); |
| 4598 | } else { |
| 4599 | add_menu_page($upper.' Folders', "{$upper} Folders", 'publish_pages', "{$edit}?post_type={$type}&type=folder", false, 'dashicons-portfolio', "{$itemKey}.5"); |
| 4600 | } |
| 4601 | |
| 4602 | $terms = get_terms( |
| 4603 | $tax_slug, |
| 4604 | [ |
| 4605 | 'hide_empty' => $hide_empty, |
| 4606 | 'parent' => 0, |
| 4607 | 'orderby' => 'meta_value_num', |
| 4608 | 'order' => 'ASC', |
| 4609 | 'hierarchical' => false, |
| 4610 | 'meta_query' => [ |
| 4611 | [ |
| 4612 | 'key' => 'wcp_custom_order', |
| 4613 | 'type' => 'NUMERIC', |
| 4614 | ], |
| 4615 | ], |
| 4616 | ] |
| 4617 | ); |
| 4618 | |
| 4619 | if ($terms) { |
| 4620 | foreach ($terms as $term) { |
| 4621 | if (isset($term->trash_count) && !empty($term->trash_count)) { |
| 4622 | if ($type == 'attachment') { |
| 4623 | add_submenu_page("{$edit}?type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type=attachment&media_folder={$term->slug}", false); |
| 4624 | } else { |
| 4625 | add_submenu_page("{$edit}?post_type={$type}&type=folder", $term->name, $term->name, 'publish_pages', "{$edit}?post_type={$type}&{$tax_slug}={$term->slug}", false); |
| 4626 | } |
| 4627 | } |
| 4628 | } |
| 4629 | } |
| 4630 | }//end foreach |
| 4631 | |
| 4632 | }//end create_menu_for_folders() |
| 4633 | |
| 4634 | |
| 4635 | /** |
| 4636 | * Add Folder Styles |
| 4637 | * |
| 4638 | * @since 1.0.0 |
| 4639 | * @access public |
| 4640 | */ |
| 4641 | function folders_admin_styles($page) |
| 4642 | { |
| 4643 | if ($page == "toplevel_page_wcp_folders_settings" || $page == "settings_page_wcp_folders_settings") { |
| 4644 | wp_enqueue_style('folder-settings', plugin_dir_url(dirname(__FILE__)).'assets/css/settings.css', [], WCP_FOLDER_VERSION); |
| 4645 | wp_enqueue_style('folders-icon', plugin_dir_url(dirname(__FILE__)).'assets/css/folder-icon.css', [], WCP_FOLDER_VERSION); |
| 4646 | wp_enqueue_style('folders-spectrum', plugin_dir_url(dirname(__FILE__)).'assets/css/spectrum.min.css', [], WCP_FOLDER_VERSION); |
| 4647 | } |
| 4648 | |
| 4649 | if ($page == "folders-settings_page_folders-upgrade-to-pro" || $page == "toplevel_page_wcp_folders_settings" || $page == "settings_page_wcp_folders_settings" || ($page == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == "upgrade-to-pro")) { |
| 4650 | wp_enqueue_style('wcp-select2', plugin_dir_url(dirname(__FILE__)).'assets/css/select2.min.css', [], WCP_FOLDER_VERSION); |
| 4651 | if ($page == "folders-settings_page_folders-upgrade-to-pro" || ($page == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == "upgrade-to-pro")) { |
| 4652 | wp_enqueue_style('wcp-admin-setting', plugin_dir_url(dirname(__FILE__)).'assets/css/admin-setting.css', [], WCP_FOLDER_VERSION); |
| 4653 | } |
| 4654 | } |
| 4655 | |
| 4656 | if (self::is_active_for_screen()) { |
| 4657 | wp_enqueue_style('wcp-folders-fa', plugin_dir_url(dirname(__FILE__)).'assets/css/folder-icon.css', [], WCP_FOLDER_VERSION); |
| 4658 | wp_enqueue_style('wcp-folders-admin', plugin_dir_url(dirname(__FILE__)).'assets/css/design.min.css', [], WCP_FOLDER_VERSION); |
| 4659 | wp_enqueue_style('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)).'assets/css/jstree.min.css', [], WCP_FOLDER_VERSION); |
| 4660 | wp_enqueue_style('folder-overlayscrollbars', WCP_FOLDER_URL.'assets/css/overlayscrollbars.min.css', [], WCP_FOLDER_VERSION); |
| 4661 | wp_enqueue_style('wcp-folders-css', plugin_dir_url(dirname(__FILE__)).'assets/css/folders.min.css', [], WCP_FOLDER_VERSION); |
| 4662 | } |
| 4663 | |
| 4664 | if ($page == "media_page_folders-media-cleaning") { |
| 4665 | wp_enqueue_style('wcp-folders-media', plugin_dir_url(dirname(__FILE__)).'assets/css/media-clean.css', [], WCP_FOLDER_VERSION); |
| 4666 | } |
| 4667 | |
| 4668 | wp_register_style('wcp-css-handle', false); |
| 4669 | wp_enqueue_style('wcp-css-handle'); |
| 4670 | $css = " |
| 4671 | .wcp-folder-upgrade-button {color: #FF5983; font-weight: bold; display: inline-block;border: solid 1px #FF5983;border-radius: 4px;padding: 0 5px;} |
| 4672 | "; |
| 4673 | if (self::is_active_for_screen()) { |
| 4674 | global $typenow; |
| 4675 | $width = get_option("wcp_dynamic_width_for_".$typenow); |
| 4676 | $width = esc_attr($width); |
| 4677 | $width = intval($width); |
| 4678 | $width = empty($width)||!is_numeric($width) ? 280 : $width; |
| 4679 | if ($width > 1200) { |
| 4680 | $width = 280; |
| 4681 | } |
| 4682 | |
| 4683 | $width = intval($width); |
| 4684 | $display_status = "wcp_dynamic_display_status_".$typenow; |
| 4685 | $display_status = get_option($display_status); |
| 4686 | if ($display_status != "hide") { |
| 4687 | if (!empty($width) && is_numeric($width)) { |
| 4688 | if (function_exists('is_rtl') && is_rtl()) { |
| 4689 | $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:".($width + 20)."px}"; |
| 4690 | $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}"; |
| 4691 | } else { |
| 4692 | $css .= "body.wp-admin #wpcontent {padding-left:".($width + 20)."px}"; |
| 4693 | } |
| 4694 | } |
| 4695 | } else { |
| 4696 | if (function_exists('is_rtl') && is_rtl()) { |
| 4697 | $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-right:20px}"; |
| 4698 | $css .= "html[dir='rtl'] body.wp-admin #wpcontent {padding-left:0px}"; |
| 4699 | } else { |
| 4700 | $css .= "body.wp-admin #wpcontent {padding-left:20px}"; |
| 4701 | } |
| 4702 | } |
| 4703 | |
| 4704 | if (!empty($width) && is_numeric($width)) { |
| 4705 | if ($width > 1200) { |
| 4706 | $width = 280; |
| 4707 | } |
| 4708 | |
| 4709 | $width = intval($width); |
| 4710 | $css .= ".wcp-content {width: ".esc_attr($width)."px}"; |
| 4711 | } |
| 4712 | |
| 4713 | global $typenow; |
| 4714 | $post_type = self::get_custom_post_type($typenow); |
| 4715 | $css .= "body:not(.woocommerce-page) .wp-list-table th#taxonomy-".esc_attr($post_type)." { width: 130px !important; } @media screen and (max-width: 1180px) { body:not(.woocommerce-page) .wp-list-table th#taxonomy-".esc_attr($post_type)." { width: 90px !important; }} @media screen and (max-width: 960px) { body:not(.woocommerce-page) .wp-list-table th#taxonomy-".esc_attr($post_type)." { width: auto !important; }}"; |
| 4716 | }//end if |
| 4717 | |
| 4718 | wp_add_inline_style('wcp-css-handle', $css); |
| 4719 | |
| 4720 | if (self::is_active_for_screen()) { |
| 4721 | global $typenow; |
| 4722 | add_filter('views_edit-'.$typenow, [$this, 'wcp_check_for_child_folders']); |
| 4723 | } |
| 4724 | |
| 4725 | }//end folders_admin_styles() |
| 4726 | |
| 4727 | |
| 4728 | /** |
| 4729 | * Get Child folder information |
| 4730 | * |
| 4731 | * @since 1.0.0 |
| 4732 | * @access public |
| 4733 | * @return $folders |
| 4734 | */ |
| 4735 | function wcp_check_for_child_folders($content) |
| 4736 | { |
| 4737 | $termId = 0; |
| 4738 | global $typenow; |
| 4739 | $post_type = self::get_custom_post_type($typenow); |
| 4740 | $term = filter_input(INPUT_GET, $post_type); |
| 4741 | if (!empty($term)) { |
| 4742 | $term = get_term_by("slug", $term, $post_type); |
| 4743 | if (!empty($term)) { |
| 4744 | $termId = $term->term_id; |
| 4745 | } |
| 4746 | } |
| 4747 | |
| 4748 | $terms = get_terms( |
| 4749 | $post_type, |
| 4750 | [ |
| 4751 | 'hide_empty' => false, |
| 4752 | 'parent' => $termId, |
| 4753 | 'orderby' => 'meta_value_num', |
| 4754 | 'order' => 'ASC', |
| 4755 | 'hierarchical' => false, |
| 4756 | 'update_count_callback' => '_update_generic_term_count', |
| 4757 | 'meta_query' => [ |
| 4758 | [ |
| 4759 | 'key' => 'wcp_custom_order', |
| 4760 | 'type' => 'NUMERIC', |
| 4761 | ], |
| 4762 | ], |
| 4763 | ] |
| 4764 | ); |
| 4765 | $optionName = "wcp_folder_display_status_".$typenow; |
| 4766 | $optionValue = get_option($optionName); |
| 4767 | $class = (!empty($optionValue) && $optionValue == "hide") ? "" : "active"; |
| 4768 | $customize_folders = get_option('customize_folders'); |
| 4769 | $show_in_page = isset($customize_folders['show_in_page']) ? $customize_folders['show_in_page'] : "hide"; |
| 4770 | if (empty($show_in_page)) { |
| 4771 | $show_in_page = "hide"; |
| 4772 | } |
| 4773 | |
| 4774 | if ($show_in_page == "show") { |
| 4775 | echo '<div class="tree-structure-content '.$class.'"><div class="tree-structure" id="list-folder-'.$termId.'" data-id="'.$termId.'">'; |
| 4776 | echo '<ul>'; |
| 4777 | foreach ($terms as $term) { |
| 4778 | $status = get_term_meta($term->term_id, "is_highlighted", true); |
| 4779 | ?> |
| 4780 | <li class="grid-view" data-id="<?php echo esc_attr($term->term_id) ?>" id="folder_<?php echo esc_attr($term->term_id) ?>"> |
| 4781 | <div class="folder-item is-folder" data-id="<?php echo esc_attr($term->term_id) ?>"> |
| 4782 | <a title='<?php echo esc_attr($term->name) ?>' id="folder_view_<?php echo esc_attr($term->term_id) ?>" class="folder-view <?php echo ($status == 1) ? "is-high" : "" ?>" data-id="<?php echo esc_attr($term->term_id) ?>"> |
| 4783 | <span class="folder item-name"><span id="wcp_folder_text_<?php echo esc_attr($term->term_id) ?>" class="folder-title"><?php echo esc_attr($term->name) ?></span></span> |
| 4784 | </a> |
| 4785 | </div> |
| 4786 | </li> |
| 4787 | <?php |
| 4788 | } |
| 4789 | |
| 4790 | echo '</ul>'; |
| 4791 | echo '<div class="clear clearfix"></div>'; |
| 4792 | echo '</div>'; |
| 4793 | echo '<div class="folders-toggle-button"><span></span></div>'; |
| 4794 | echo '</div>'; |
| 4795 | }//end if |
| 4796 | |
| 4797 | $allowedTags = [ |
| 4798 | 'a' => [ |
| 4799 | 'href' => [], |
| 4800 | 'title' => [], |
| 4801 | 'target' => [], |
| 4802 | 'class' => [] |
| 4803 | ], |
| 4804 | "span" => [ |
| 4805 | 'class' => [] |
| 4806 | ] |
| 4807 | ]; |
| 4808 | |
| 4809 | if(isset($content['mine'])) { |
| 4810 | unset($content['mine']); |
| 4811 | } |
| 4812 | if (!empty($content) && is_array($content)) { |
| 4813 | echo '<ul class="subsubsub">'; |
| 4814 | foreach ($content as $k => $v) { |
| 4815 | echo "<li class='".esc_attr($k)."'>".wp_kses($v, $allowedTags)."</li>"; |
| 4816 | } |
| 4817 | |
| 4818 | echo '</ul>'; |
| 4819 | } |
| 4820 | |
| 4821 | }//end wcp_check_for_child_folders() |
| 4822 | |
| 4823 | |
| 4824 | /** |
| 4825 | * Add Folder Scripts to admin |
| 4826 | * |
| 4827 | * @since 1.0.0 |
| 4828 | * @access public |
| 4829 | * @return $folders |
| 4830 | */ |
| 4831 | function folders_admin_scripts($hook) |
| 4832 | { |
| 4833 | if ($hook == "toplevel_page_wcp_folders_settings" || $hook == "settings_page_wcp_folders_settings") { |
| 4834 | wp_enqueue_script('folders-spectrum', plugin_dir_url(dirname(__FILE__)).'assets/js/spectrum.min.js', ['jquery'], WCP_FOLDER_VERSION); |
| 4835 | } |
| 4836 | |
| 4837 | if ($hook == "folders-settings_page_folders-upgrade-to-pro" || $hook == "toplevel_page_wcp_folders_settings" || $hook == "settings_page_wcp_folders_settings" || ($hook == "settings_page_wcp_folders_settings" && isset($_GET['setting_page']) && $_GET['setting_page'] == "upgrade-to-pro")) { |
| 4838 | wp_enqueue_script('folders-select2', plugin_dir_url(dirname(__FILE__)).'assets/js/select2.min.js', ['jquery'], WCP_FOLDER_VERSION); |
| 4839 | } |
| 4840 | |
| 4841 | if (self::is_active_for_screen()) { |
| 4842 | remove_filter("terms_clauses", "TO_apply_order_filter"); |
| 4843 | |
| 4844 | global $typenow; |
| 4845 | // Free/Pro Version change |
| 4846 | wp_dequeue_script("jquery-jstree"); |
| 4847 | wp_enqueue_script('wcp-folders-jstree', plugin_dir_url(dirname(__FILE__)).'assets/js/jstree.min.js', ['jquery'], WCP_FOLDER_VERSION); |
| 4848 | wp_enqueue_script('folders-overlayscrollbars', WCP_FOLDER_URL.'assets/js/jquery.overlayscrollbars.min.js', [], WCP_FOLDER_VERSION); |
| 4849 | wp_enqueue_script('wcp-folders-custom', plugin_dir_url(dirname(__FILE__)).'assets/js/folders.min.js', ['jquery', 'jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'backbone'], WCP_FOLDER_VERSION); |
| 4850 | wp_enqueue_script('wcp-jquery-touch', plugin_dir_url(dirname(__FILE__)).'assets/js/jquery.ui.touch-punch.min.js', ['jquery'], WCP_FOLDER_VERSION); |
| 4851 | |
| 4852 | $post_type = self::get_custom_post_type($typenow); |
| 4853 | |
| 4854 | $post_status = ""; |
| 4855 | if (isset($_GET['post_status']) && !empty($_GET['post_status'])) { |
| 4856 | $post_status = folders_sanitize_text('post_status', 'get'); |
| 4857 | } |
| 4858 | |
| 4859 | if ($typenow == "attachment") { |
| 4860 | $admin_url = admin_url("upload.php?post_type=attachment&media_folder="); |
| 4861 | } else { |
| 4862 | $admin_url = admin_url("edit.php?post_type=".$typenow); |
| 4863 | $search = filter_input(INPUT_GET, "s"); |
| 4864 | if (!empty($search)) { |
| 4865 | $admin_url .= "&s=".esc_attr($search); |
| 4866 | } |
| 4867 | |
| 4868 | if (!empty($post_status)) { |
| 4869 | $admin_url .= "&post_status=".sanitize_text_field($post_status); |
| 4870 | } |
| 4871 | |
| 4872 | $admin_url .= "&".esc_attr($post_type)."="; |
| 4873 | } |
| 4874 | |
| 4875 | $current_url = $admin_url; |
| 4876 | $post_value = filter_input(INPUT_GET, $post_type); |
| 4877 | if (!empty($post_value)) { |
| 4878 | $current_url .= esc_attr($post_value); |
| 4879 | } |
| 4880 | |
| 4881 | $is_active = 1; |
| 4882 | $folders = -1; |
| 4883 | // For free: upgrade URL, for Pro: Register Key URL |
| 4884 | $register_url = $this->getFoldersUpgradeURL(); |
| 4885 | |
| 4886 | $is_rtl = 0; |
| 4887 | if (function_exists('is_rtl') && is_rtl()) { |
| 4888 | $is_rtl = 1; |
| 4889 | } |
| 4890 | |
| 4891 | $can_manage_folder = current_user_can("manage_categories") ? 1 : 0; |
| 4892 | $width = get_option("wcp_dynamic_width_for_".$typenow); |
| 4893 | $width = intval($width); |
| 4894 | $width = empty($width)||!is_numeric($width) ? 280 : $width; |
| 4895 | if ($width > 1200) { |
| 4896 | $width = 280; |
| 4897 | } |
| 4898 | |
| 4899 | $post_type = self::get_custom_post_type($typenow); |
| 4900 | $taxonomy_status = 0; |
| 4901 | $selected_taxonomy = ""; |
| 4902 | $post_value = filter_input(INPUT_GET, $post_type); |
| 4903 | if (empty($post_value)) { |
| 4904 | $taxonomy_status = 1; |
| 4905 | } else { |
| 4906 | $selected_taxonomy = esc_attr($post_value); |
| 4907 | |
| 4908 | $term = get_term_by('slug', $selected_taxonomy, $post_type); |
| 4909 | if (!empty($term) && is_object($term)) { |
| 4910 | $selected_taxonomy = $term->term_id; |
| 4911 | } else { |
| 4912 | $selected_taxonomy = ""; |
| 4913 | } |
| 4914 | } |
| 4915 | |
| 4916 | $customize_folders = get_option('customize_folders'); |
| 4917 | $show_in_page = isset($customize_folders['show_in_page']) ? $customize_folders['show_in_page'] : "hide"; |
| 4918 | if (empty($show_in_page)) { |
| 4919 | $show_in_page = "hide"; |
| 4920 | } |
| 4921 | |
| 4922 | $taxonomies = self::get_terms_hierarchical($post_type); |
| 4923 | $use_folder_undo = !isset($customize_folders['use_folder_undo']) ? "yes" : $customize_folders['use_folder_undo']; |
| 4924 | $defaultTimeout = !isset($customize_folders['default_timeout']) ? 5 : intval($customize_folders['default_timeout']); |
| 4925 | if (empty($defaultTimeout) || !is_numeric($defaultTimeout) || $defaultTimeout < 0) { |
| 4926 | $defaultTimeout = 5; |
| 4927 | } |
| 4928 | |
| 4929 | $defaultTimeout = ($defaultTimeout * 1000); |
| 4930 | |
| 4931 | $folder_settings = []; |
| 4932 | foreach ($taxonomies as $taxonomy) { |
| 4933 | $is_sticky = get_term_meta($taxonomy->term_id, "is_folder_sticky", true); |
| 4934 | $is_high = get_term_meta($taxonomy->term_id, "is_highlighted", true); |
| 4935 | $folder_settings[] = [ |
| 4936 | 'folder_id' => $taxonomy->term_id, |
| 4937 | 'is_sticky' => intval($is_sticky), |
| 4938 | 'is_high' => intval($is_high), |
| 4939 | 'nonce' => wp_create_nonce('wcp_folder_term_'.$taxonomy->term_id), |
| 4940 | 'is_deleted' => 0, |
| 4941 | 'slug' => $taxonomy->slug, |
| 4942 | 'folder_count' => intval($taxonomy->trash_count), |
| 4943 | ]; |
| 4944 | } |
| 4945 | |
| 4946 | $default_folders = get_option("default_folders"); |
| 4947 | $default_folder = ""; |
| 4948 | if (isset($default_folders["attachment"])) { |
| 4949 | $default_folder = $default_folders["attachment"]; |
| 4950 | } |
| 4951 | |
| 4952 | $use_shortcuts = !isset($customize_folders['use_shortcuts']) ? "yes" : $customize_folders['use_shortcuts']; |
| 4953 | |
| 4954 | $currentPage = filter_input(INPUT_GET, 'paged'); |
| 4955 | if (!empty($currentPage)) { |
| 4956 | $currentPage = intval($currentPage); |
| 4957 | } else { |
| 4958 | $currentPage = 1; |
| 4959 | } |
| 4960 | |
| 4961 | $lang = $this->js_strings(); |
| 4962 | |
| 4963 | $hasStars = self::check_for_setting("has_stars", "general"); |
| 4964 | $hasChild = self::check_for_setting("has_child", "general"); |
| 4965 | $hasChild = empty($hasChild) ? 0 : 1; |
| 4966 | $hasStars = empty($hasStars) ? 0 : 1; |
| 4967 | wp_localize_script( |
| 4968 | 'wcp-folders-custom', |
| 4969 | 'wcp_settings', |
| 4970 | [ |
| 4971 | 'ajax_url' => admin_url('admin-ajax.php'), |
| 4972 | 'upgrade_url' => $this->getFoldersUpgradeURL(), |
| 4973 | 'post_type' => $typenow, |
| 4974 | 'custom_type' => $post_type, |
| 4975 | 'page_url' => $admin_url, |
| 4976 | 'current_url' => $current_url, |
| 4977 | 'ajax_image' => plugin_dir_url(dirname(__FILE__))."assets/images/ajax-loader.gif", |
| 4978 | 'is_key_active' => $is_active, |
| 4979 | 'folders' => $folders, |
| 4980 | 'register_url' => $register_url, |
| 4981 | 'isRTL' => $is_rtl, |
| 4982 | 'nonce' => wp_create_nonce('wcp_folder_nonce_'.$typenow), |
| 4983 | 'can_manage_folder' => $can_manage_folder, |
| 4984 | 'folder_width' => $width, |
| 4985 | 'taxonomy_status' => $taxonomy_status, |
| 4986 | 'selected_taxonomy' => $selected_taxonomy, |
| 4987 | 'show_in_page' => $show_in_page, |
| 4988 | 'svg_file' => WCP_FOLDER_URL.'assets/images/pin.png', |
| 4989 | 'taxonomies' => $taxonomies, |
| 4990 | 'folder_settings' => $folder_settings, |
| 4991 | 'hasStars' => $hasStars, |
| 4992 | 'hasChildren' => $hasChild, |
| 4993 | 'currentPage' => $currentPage, |
| 4994 | 'useFolderUndo' => $use_folder_undo, |
| 4995 | 'defaultTimeout' => $defaultTimeout, |
| 4996 | 'default_folder' => $default_folder, |
| 4997 | 'use_shortcuts' => $use_shortcuts, |
| 4998 | 'post_status' => $post_status, |
| 4999 | 'lang' => $lang, |
| 5000 | ] |
| 5001 | ); |
| 5002 | } else { |
| 5003 | self::is_add_update_screen(); |
| 5004 | }//end if |
| 5005 | |
| 5006 | if ($hook == "media-new.php") { |
| 5007 | if (self::is_for_this_post_type('attachment') || self::is_for_this_post_type('media')) { |
| 5008 | wp_enqueue_style('folders-media', WCP_FOLDER_URL.'assets/css/new-media.css'); |
| 5009 | $is_active = 1; |
| 5010 | $folders = -1; |
| 5011 | |
| 5012 | $hasStars = self::check_for_setting("has_stars", "general"); |
| 5013 | $hasChild = self::check_for_setting("has_child", "general"); |
| 5014 | $hasChild = empty($hasChild) ? 0 : 1; |
| 5015 | $hasStars = empty($hasStars) ? 0 : 1; |
| 5016 | |
| 5017 | wp_enqueue_script('wcp-folders-add-new-media', plugin_dir_url(dirname(__FILE__)).'assets/js/new-media.js', ['jquery'], WCP_FOLDER_VERSION); |
| 5018 | wp_localize_script( |
| 5019 | 'wcp-folders-add-new-media', |
| 5020 | 'folders_media_options', |
| 5021 | [ |
| 5022 | 'terms' => self::get_terms_hierarchical('media_folder'), |
| 5023 | 'taxonomy' => get_taxonomy('media_folder'), |
| 5024 | 'ajax_url' => admin_url("admin-ajax.php"), |
| 5025 | 'activate_url' => $this->getFoldersUpgradeURL(), |
| 5026 | 'nonce' => wp_create_nonce('wcp_folder_nonce_attachment'), |
| 5027 | 'is_key_active' => $is_active, |
| 5028 | 'folders' => $folders, |
| 5029 | 'hasStars' => $hasStars, |
| 5030 | 'hasChildren' => $hasChild, |
| 5031 | ] |
| 5032 | ); |
| 5033 | }//end if |
| 5034 | }//end if |
| 5035 | |
| 5036 | }//end folders_admin_scripts() |
| 5037 | |
| 5038 | |
| 5039 | /** |
| 5040 | * Translated strings for javascript |
| 5041 | * |
| 5042 | * @since 1.0.0 |
| 5043 | * @access public |
| 5044 | */ |
| 5045 | public function js_strings() |
| 5046 | { |
| 5047 | return [ |
| 5048 | "ALL_FOLDERS" => esc_html__("All Folders", "folders"), |
| 5049 | "NEW_FOLDER" => esc_html__("New folder", "folders"), |
| 5050 | "NEW_SUB_FOLDER" => esc_html__("New Sub-folder", "folders"), |
| 5051 | "RENAME" => esc_html__("Rename", "folders"), |
| 5052 | "REMOVE_STICKY_FOLDER" => esc_html__("Remove Sticky Folder", "folders"), |
| 5053 | "STICKY_FOLDER" => esc_html__("Sticky Folder", "folders"), |
| 5054 | "REMOVE_STAR" => esc_html__("Remove Star", "folders"), |
| 5055 | "ADD_STAR" => esc_html__("Add Star", "folders"), |
| 5056 | "LOCK_FOLDER" => esc_html__("Lock Folder", "folders"), |
| 5057 | "UNLOCK_FOLDER" => esc_html__("Unlock Folder", "folders"), |
| 5058 | "DUPLICATE_FOLDER" => esc_html__("Duplicate folder", "folders"), |
| 5059 | "DOWNLOAD_ZIP" => esc_html__("Download Zip", "folders"), |
| 5060 | "OPEN_THIS_FOLDER" => esc_html__("Open this folder by default", "folders"), |
| 5061 | "REMOVE_THIS_FOLDER" => esc_html__("Remove default folder", "folders"), |
| 5062 | "CUT" => esc_html__("Cut", "folders"), |
| 5063 | "COPY" => esc_html__("Copy", "folders"), |
| 5064 | "PASTE" => esc_html__("Paste", "folders"), |
| 5065 | "DELETE" => esc_html__("Delete", "folders"), |
| 5066 | "BULK_ORGANIZE" => esc_html__("Bulk Organize", "folders"), |
| 5067 | "DRAG_AND_DROP" => esc_html__("Drag and drop your media files to the relevant folders", "folders"), |
| 5068 | "SELECT_ALL" => esc_html__("Select All", "folders"), |
| 5069 | "MOVE_SELECTED_FILES" => esc_html__("Move Selected files to:", "folders"), |
| 5070 | "UPLOADING_FILES" => esc_html__("Uploading files", "folders"), |
| 5071 | "SELECT_ITEMS_TO_MOVE" => esc_html__("Please select items to move in folder", "folders"), |
| 5072 | "LOADING_FILES" => esc_html__("Loading...", "folders"), |
| 5073 | "SELECT_FOLDER" => esc_html__("Select Folder", "folders"), |
| 5074 | "UNASSIGNED" => esc_html__("(Unassigned)", "folders"), |
| 5075 | "SELECT_ITEMS" => esc_html__("Select Items to move", "folders"), |
| 5076 | "ONE_ITEM" => esc_html__("1 Item", "folders"), |
| 5077 | "ITEMS" => esc_html__("Items", "folders"), |
| 5078 | "SELECTED" => esc_html__("Selected", "folders"), |
| 5079 | "MOVE_TO_FOLDER" => esc_html__("Move to Folder", "folders"), |
| 5080 | "DELETE_FOLDER_MESSAGE" => esc_html__("Are you sure you want to delete the selected folder?", "folders"), |
| 5081 | "ITEM_NOT_DELETED" => esc_html__("Items in the folder will not be deleted.", "folders"), |
| 5082 | "DELETE_FOLDERS_MESSAGE" => esc_html__("Are you sure you want to delete the selected folders?", "folders"), |
| 5083 | "ITEMS_NOT_DELETED" => esc_html__("Items in the selected folders will not be deleted.", "folders"), |
| 5084 | "SELECT_AT_LEAST_ONE_FOLDER" => esc_html__("Please select at least one folder to delete", "folders"), |
| 5085 | "YES_DELETE_IT" => esc_html__("Yes, Delete it!", "folders"), |
| 5086 | "SUBMIT" => esc_html__("Submit", "folders"), |
| 5087 | "EXPAND" => esc_html__("Expand", "folders"), |
| 5088 | "COLLAPSE" => esc_html__("Collapse", "folders"), |
| 5089 | "DUPLICATING_FOLDER" => esc_html__("Duplicating to a new folder", "folders"), |
| 5090 | "ADD_NEW_FOLDER" => esc_html__("Add a new folder", "folders"), |
| 5091 | "ACTIVATE" => [ |
| 5092 | "REMOVE_STAR" => esc_html__("Remove Star (Activate)", "folders"), |
| 5093 | "ADD_STAR" => esc_html__("Add a Star (Activate)", "folders"), |
| 5094 | "STICKY_FOLDER" => esc_html__("Sticky Folder (Activate)", "folders"), |
| 5095 | "NEW_SUB_FOLDER" => esc_html__("New Sub-folder (Activate)", "folders"), |
| 5096 | "LOCK_FOLDER" => esc_html__("Lock Folder (Activate)", "folders"), |
| 5097 | "DUPLICATE_FOLDER" => esc_html__("Duplicate folder (Activate)", "folders"), |
| 5098 | "DOWNLOAD_ZIP" => esc_html__("Download Zip (Activate)", "folders"), |
| 5099 | ], |
| 5100 | "PRO" => [ |
| 5101 | "ADD_STAR" => esc_html__("Add a Star (Pro)", "folders"), |
| 5102 | "REMOVE_STAR" => esc_html__("Remove Star (Pro)", "folders"), |
| 5103 | "STICKY_FOLDER" => esc_html__("Sticky Folder (Pro)", "folders"), |
| 5104 | "NEW_SUB_FOLDER" => esc_html__("New Sub-folder (Pro)", "folders"), |
| 5105 | "LOCK_FOLDER" => esc_html__("Lock Folder (Pro)", "folders"), |
| 5106 | "DUPLICATE_FOLDER" => esc_html__("Duplicate folder (Pro)", "folders"), |
| 5107 | "DOWNLOAD_ZIP" => esc_html__("Download Zip (Pro)", "folders"), |
| 5108 | "OPEN_THIS_FOLDER" => esc_html__("Open this folder by default (Pro)", "folders"), |
| 5109 | ], |
| 5110 | ]; |
| 5111 | |
| 5112 | }//end js_strings() |
| 5113 | |
| 5114 | |
| 5115 | /** |
| 5116 | * Redirect to folders settings page on Plugin activation |
| 5117 | * |
| 5118 | * @since 1.0.0 |
| 5119 | * @access public |
| 5120 | */ |
| 5121 | public function plugin_action_links($links) |
| 5122 | { |
| 5123 | array_unshift($links, '<a href="'.admin_url("admin.php?page=wcp_folders_settings").'" >'.esc_html__('Settings', 'folders').'</a>'); |
| 5124 | $links['need_help'] = '<a target="_blank" href="https://premio.io/help/folders/?utm_source=pluginspage" >'.__('Need help?', 'folders').'</a>'; |
| 5125 | |
| 5126 | // PRO link for only for FREE |
| 5127 | $links['pro'] = '<a class="wcp-folder-upgrade-button" href="'.$this->getFoldersUpgradeURL().'" >'.__('Upgrade', 'folders').'</a>'; |
| 5128 | return $links; |
| 5129 | |
| 5130 | }//end plugin_action_links() |
| 5131 | |
| 5132 | |
| 5133 | /** |
| 5134 | * Create instance of Folder class |
| 5135 | * |
| 5136 | * @since 1.0.0 |
| 5137 | * @access public |
| 5138 | * @return $folders |
| 5139 | */ |
| 5140 | public static function get_instance() |
| 5141 | { |
| 5142 | if (empty(self::$instance)) { |
| 5143 | // Do not change Class name here |
| 5144 | self::$instance = new WCP_Folders(); |
| 5145 | } |
| 5146 | |
| 5147 | return self::$instance; |
| 5148 | |
| 5149 | }//end get_instance() |
| 5150 | |
| 5151 | |
| 5152 | /** |
| 5153 | * Will check for empty folder order |
| 5154 | * |
| 5155 | * @since 1.0.0 |
| 5156 | * @access public |
| 5157 | */ |
| 5158 | public function check_and_set_post_type() |
| 5159 | { |
| 5160 | $options = get_option('folders_settings'); |
| 5161 | $old_plugin_status = 0; |
| 5162 | $post_array = []; |
| 5163 | if (!empty($options) && is_array($options)) { |
| 5164 | foreach ($options as $key => $val) { |
| 5165 | if (!(strpos($key, 'folders4') === false) && $old_plugin_status == 0) { |
| 5166 | $old_plugin_status = 1; |
| 5167 | } |
| 5168 | |
| 5169 | if (in_array($key, ["folders4page", "folders4post", "folders4attachment"])) { |
| 5170 | $post_array[] = str_replace("folders4", "", $key); |
| 5171 | } |
| 5172 | } |
| 5173 | } else { |
| 5174 | $post_array = [ |
| 5175 | "page", |
| 5176 | "post", |
| 5177 | "attachment", |
| 5178 | ]; |
| 5179 | } |
| 5180 | |
| 5181 | if ($old_plugin_status == 1) { |
| 5182 | update_option("folders_show_in_menu", "on"); |
| 5183 | $old_plugin_var = get_option("folder_old_plugin_status"); |
| 5184 | if (empty($old_plugin_var) || $old_plugin_var == null) { |
| 5185 | update_option("folder_old_plugin_status", "1"); |
| 5186 | } |
| 5187 | |
| 5188 | update_option('folders_settings', $post_array); |
| 5189 | self::set_default_values_if_not_exists(); |
| 5190 | } |
| 5191 | |
| 5192 | if (!empty($post_array) && get_option('folders_settings') === false) { |
| 5193 | update_option('folders_settings', $post_array); |
| 5194 | update_option("folders_show_in_menu", "off"); |
| 5195 | } |
| 5196 | |
| 5197 | }//end check_and_set_post_type() |
| 5198 | |
| 5199 | |
| 5200 | /** |
| 5201 | * Migrate data for old versions |
| 5202 | * |
| 5203 | * @since 1.0.0 |
| 5204 | * @access public |
| 5205 | */ |
| 5206 | public static function activate() |
| 5207 | { |
| 5208 | premio_folders_plugin_check_for_setting(); |
| 5209 | $folder_setting = get_option("folders_settings"); |
| 5210 | if ($folder_setting === false) { |
| 5211 | add_option("wcp_folder_version_267", 1); |
| 5212 | } |
| 5213 | |
| 5214 | update_option("folders_show_in_menu", "off"); |
| 5215 | $option = get_option("folder_redirect_status"); |
| 5216 | if ($option === false) { |
| 5217 | add_option("folder_intro_box", "show"); |
| 5218 | } |
| 5219 | |
| 5220 | update_option("folder_redirect_status", 1); |
| 5221 | |
| 5222 | }//end activate() |
| 5223 | |
| 5224 | |
| 5225 | /** |
| 5226 | * Remove folder data on deactivation |
| 5227 | * |
| 5228 | * @since 1.0.0 |
| 5229 | * @access public |
| 5230 | */ |
| 5231 | public static function deactivate() |
| 5232 | { |
| 5233 | $customize_folders = get_option('customize_folders'); |
| 5234 | $DS = DIRECTORY_SEPARATOR; |
| 5235 | $dirName = ABSPATH."wp-content{$DS}plugins{$DS}folders-pro{$DS}"; |
| 5236 | $is_pro = get_option("folders_pro_is_in_process"); |
| 5237 | if (!is_dir($dirName) && $is_pro === false && isset($customize_folders['remove_folders_when_removed']) && $customize_folders['remove_folders_when_removed'] == "on") { |
| 5238 | self::$folders = 0; |
| 5239 | self::remove_folder_by_taxonomy("media_folder"); |
| 5240 | self::remove_folder_by_taxonomy("folder"); |
| 5241 | self::remove_folder_by_taxonomy("post_folder"); |
| 5242 | $post_types = get_post_types([], 'objects'); |
| 5243 | $post_array = [ |
| 5244 | "page", |
| 5245 | "post", |
| 5246 | "attachment", |
| 5247 | ]; |
| 5248 | foreach ($post_types as $post_type) { |
| 5249 | if (!in_array($post_type->name, $post_array)) { |
| 5250 | self::remove_folder_by_taxonomy($post_type->name.'_folder'); |
| 5251 | } |
| 5252 | } |
| 5253 | |
| 5254 | delete_option('customize_folders'); |
| 5255 | delete_option('default_folders'); |
| 5256 | delete_option('folders_show_in_menu'); |
| 5257 | delete_option('folder_redirect_status'); |
| 5258 | delete_option('folders_settings'); |
| 5259 | delete_option('premio_folder_options'); |
| 5260 | delete_option('folders_settings_updated'); |
| 5261 | }//end if |
| 5262 | |
| 5263 | }//end deactivate() |
| 5264 | |
| 5265 | |
| 5266 | /** |
| 5267 | * Register folder settings |
| 5268 | * |
| 5269 | * @since 1.0.0 |
| 5270 | * @access public |
| 5271 | */ |
| 5272 | function folders_register_settings() |
| 5273 | { |
| 5274 | register_setting('folders_settings', 'folders_settings1', 'folders_settings_validate'); |
| 5275 | register_setting('default_folders', 'default_folders'); |
| 5276 | register_setting('customize_folders', 'customize_folders'); |
| 5277 | |
| 5278 | self::check_and_set_post_type(); |
| 5279 | |
| 5280 | $getData = filter_input_array(INPUT_GET); |
| 5281 | if (isset($getData['hide_menu']) && $getData['hide_menu'] == "scan-files" && isset($getData['nonce'])) { |
| 5282 | if (current_user_can('manage_options')) { |
| 5283 | $nonce = $getData['nonce']; |
| 5284 | if (wp_verify_nonce($nonce, "folders-scan-files")) { |
| 5285 | $customize_folders = get_option('customize_folders'); |
| 5286 | $customize_folders['folders_media_cleaning'] = "no"; |
| 5287 | update_option("customize_folders", $customize_folders); |
| 5288 | wp_redirect(admin_url("upload.php")); |
| 5289 | exit; |
| 5290 | } |
| 5291 | } |
| 5292 | } |
| 5293 | |
| 5294 | $option = get_option("folder_redirect_status"); |
| 5295 | if ($option == 1) { |
| 5296 | update_option("folder_redirect_status", 2); |
| 5297 | wp_redirect(admin_url("admin.php?page=wcp_folders_settings")); |
| 5298 | exit; |
| 5299 | } |
| 5300 | |
| 5301 | }//end folders_register_settings() |
| 5302 | |
| 5303 | |
| 5304 | /** |
| 5305 | * Folders upgrade URL |
| 5306 | * |
| 5307 | * @since 1.0.0 |
| 5308 | * @access public |
| 5309 | * @return $url |
| 5310 | */ |
| 5311 | function getFoldersUpgradeURL() |
| 5312 | { |
| 5313 | $customize_folders = get_option("customize_folders"); |
| 5314 | if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") { |
| 5315 | return admin_url("options-general.php?page=wcp_folders_settings&setting_page=upgrade-to-pro"); |
| 5316 | } else { |
| 5317 | return admin_url("admin.php?page=folders-upgrade-to-pro"); |
| 5318 | } |
| 5319 | |
| 5320 | }//end getFoldersUpgradeURL() |
| 5321 | |
| 5322 | |
| 5323 | /** |
| 5324 | * Returns folders settings URL |
| 5325 | * |
| 5326 | * @since 1.0.0 |
| 5327 | * @access public |
| 5328 | * @return $url |
| 5329 | */ |
| 5330 | function getFolderSettingsURL() |
| 5331 | { |
| 5332 | $customize_folders = get_option("customize_folders"); |
| 5333 | if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") { |
| 5334 | return admin_url("options-general.php?page=wcp_folders_settings"); |
| 5335 | } else { |
| 5336 | return admin_url("admin.php?page=wcp_folders_settings"); |
| 5337 | } |
| 5338 | |
| 5339 | }//end getFolderSettingsURL() |
| 5340 | |
| 5341 | |
| 5342 | /** |
| 5343 | * Checking folders setting is inside wordpress setting menu |
| 5344 | * |
| 5345 | * @since 1.0.0 |
| 5346 | * @access public |
| 5347 | */ |
| 5348 | function isFoldersInSettings() |
| 5349 | { |
| 5350 | $customize_folders = get_option("customize_folders"); |
| 5351 | if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") { |
| 5352 | return true; |
| 5353 | } |
| 5354 | |
| 5355 | return false; |
| 5356 | |
| 5357 | }//end isFoldersInSettings() |
| 5358 | |
| 5359 | |
| 5360 | /** |
| 5361 | * Add Checkbox to table head for page, post, attachments |
| 5362 | * |
| 5363 | * @since 1.0.0 |
| 5364 | * @access public |
| 5365 | * @return $defaults |
| 5366 | */ |
| 5367 | function wcp_manage_columns_head($defaults, $d="") |
| 5368 | { |
| 5369 | global $typenow; |
| 5370 | $type = $typenow; |
| 5371 | $action = $this->getRequestVar("action"); |
| 5372 | if ($action == 'inline-save') { |
| 5373 | $post_type = $this->getRequestVar('post_type'); |
| 5374 | $type = self::sanitize_options($post_type); |
| 5375 | } |
| 5376 | |
| 5377 | $options = get_option("folders_settings"); |
| 5378 | if (is_array($options) && in_array($type, $options)) { |
| 5379 | $columns = ([ |
| 5380 | 'wcp_move' => '<div class="wcp-move-multiple wcp-col" title="'.esc_html__('Move selected items', 'folders').'"><span class="dashicons dashicons-move"></span><div class="wcp-items"></div></div>', |
| 5381 | ] + $defaults); |
| 5382 | return $columns; |
| 5383 | } |
| 5384 | |
| 5385 | return $defaults; |
| 5386 | |
| 5387 | }//end wcp_manage_columns_head() |
| 5388 | |
| 5389 | |
| 5390 | /** |
| 5391 | * Add Checkbox to table body content for page, post, attachments |
| 5392 | * |
| 5393 | * @since 1.0.0 |
| 5394 | * @access public |
| 5395 | * @return $column_name |
| 5396 | */ |
| 5397 | function wcp_manage_columns_content($column_name, $post_ID) |
| 5398 | { |
| 5399 | $postIDs = self::$postIds; |
| 5400 | if (!is_array($postIDs)) { |
| 5401 | $postIDs = []; |
| 5402 | } |
| 5403 | |
| 5404 | if (!in_array($post_ID, $postIDs)) { |
| 5405 | $postIDs[] = $post_ID; |
| 5406 | self::$postIds = $postIDs; |
| 5407 | global $typenow; |
| 5408 | $type = $typenow; |
| 5409 | $action = $this->getRequestVar('action'); |
| 5410 | if ($action == 'inline-save') { |
| 5411 | $post_type = $this->getRequestVar('post_type'); |
| 5412 | $type = self::sanitize_options($post_type); |
| 5413 | } |
| 5414 | |
| 5415 | $options = get_option("folders_settings"); |
| 5416 | if (is_array($options) && in_array($type, $options)) { |
| 5417 | if ($column_name == 'wcp_move') { |
| 5418 | $title = get_the_title(); |
| 5419 | if (strlen($title) > 20) { |
| 5420 | $title = substr($title, 0, 20)."..."; |
| 5421 | } |
| 5422 | |
| 5423 | echo "<div class='wcp-move-file' data-id='".esc_attr($post_ID)."'><span class='wcp-move dashicons dashicons-move' data-id='".esc_attr($post_ID)."'></span><span class='wcp-item' data-object-id='".esc_attr($post_ID)."'>".esc_attr($title)."</span></div>"; |
| 5424 | } |
| 5425 | } |
| 5426 | }//end if |
| 5427 | |
| 5428 | }//end wcp_manage_columns_content() |
| 5429 | |
| 5430 | |
| 5431 | /** |
| 5432 | * Exclude empty folders |
| 5433 | * |
| 5434 | * @since 1.0.0 |
| 5435 | * @access public |
| 5436 | * @return $query |
| 5437 | */ |
| 5438 | function taxonomy_archive_exclude_children($query) |
| 5439 | { |
| 5440 | $options = get_option("folders_settings"); |
| 5441 | if (!empty($options)) { |
| 5442 | $taxonomy_slugs = []; |
| 5443 | foreach ($options as $option) { |
| 5444 | $taxonomy_slugs[] = self::get_custom_post_type($option); |
| 5445 | } |
| 5446 | |
| 5447 | if (!empty($taxonomy_slugs)) { |
| 5448 | $i = 0; |
| 5449 | foreach ($query->tax_query->queries as $tax_query_item) { |
| 5450 | if (empty($taxonomy_slugs) || (isset($tax_query_item['taxonomy']) && in_array($tax_query_item['taxonomy'], $taxonomy_slugs))) { |
| 5451 | $query->tax_query->queries[$i]['include_children'] = 0; |
| 5452 | } |
| 5453 | } |
| 5454 | } |
| 5455 | } |
| 5456 | |
| 5457 | }//end taxonomy_archive_exclude_children() |
| 5458 | |
| 5459 | |
| 5460 | /** |
| 5461 | * Add folder settins to WP menu |
| 5462 | * |
| 5463 | * @since 1.0.0 |
| 5464 | * @access public |
| 5465 | */ |
| 5466 | public function admin_menu() |
| 5467 | { |
| 5468 | $customize_folders = get_option("customize_folders"); |
| 5469 | if (isset($customize_folders['show_folder_in_settings']) && $customize_folders['show_folder_in_settings'] == "yes") { |
| 5470 | add_options_page( |
| 5471 | esc_html__('Folders Settings', 'folders'), |
| 5472 | esc_html__('Folders Settings', 'folders'), |
| 5473 | 'manage_options', |
| 5474 | 'wcp_folders_settings', |
| 5475 | [ |
| 5476 | $this, |
| 5477 | 'wcp_folders_settings', |
| 5478 | ] |
| 5479 | ); |
| 5480 | } else { |
| 5481 | $menu_slug = 'wcp_folders_settings'; |
| 5482 | |
| 5483 | // Add menu item for settings page |
| 5484 | $page_title = esc_html__('Folders', 'folders'); |
| 5485 | $menu_title = esc_html__('Folders Settings', 'folders'); |
| 5486 | $capability = 'manage_options'; |
| 5487 | $callback = [ |
| 5488 | $this, |
| 5489 | "wcp_folders_settings", |
| 5490 | ]; |
| 5491 | $icon_url = 'dashicons-category'; |
| 5492 | $position = 99; |
| 5493 | add_menu_page($page_title, $menu_title, $capability, $menu_slug, $callback, $icon_url, $position); |
| 5494 | |
| 5495 | $getData = filter_input_array(INPUT_GET); |
| 5496 | if (isset($getData['hide_folder_recommended_plugin']) && isset($getData['nonce'])) { |
| 5497 | if (current_user_can('manage_options')) { |
| 5498 | $nonce = $getData['nonce']; |
| 5499 | if (wp_verify_nonce($nonce, "folder_recommended_plugin")) { |
| 5500 | update_option('hide_folder_recommended_plugin', "1"); |
| 5501 | } |
| 5502 | } |
| 5503 | } |
| 5504 | |
| 5505 | $recommended_plugin = get_option("hide_folder_recommended_plugin"); |
| 5506 | if ($recommended_plugin === false) { |
| 5507 | add_submenu_page( |
| 5508 | $menu_slug, |
| 5509 | esc_html__('Recommended Plugins', 'folders'), |
| 5510 | esc_html__('Recommended Plugins', 'folders'), |
| 5511 | 'manage_options', |
| 5512 | 'recommended-folder-plugins', |
| 5513 | [ |
| 5514 | $this, |
| 5515 | 'recommended_plugins', |
| 5516 | ] |
| 5517 | ); |
| 5518 | } |
| 5519 | |
| 5520 | // Do not Change Free/Pro Change for menu |
| 5521 | add_submenu_page( |
| 5522 | $menu_slug, |
| 5523 | esc_html__('Upgrade to Pro', 'folders'), |
| 5524 | esc_html__('Upgrade to Pro', 'folders'), |
| 5525 | 'manage_options', |
| 5526 | 'folders-upgrade-to-pro', |
| 5527 | [ |
| 5528 | $this, |
| 5529 | 'wcp_folders_upgrade_or_register', |
| 5530 | ] |
| 5531 | ); |
| 5532 | |
| 5533 | // Add menu for media cleaning |
| 5534 | $show_in_page = !isset($customize_folders['folders_media_cleaning']) ? "yes" : $customize_folders['folders_media_cleaning']; |
| 5535 | |
| 5536 | if ($show_in_page == "yes") { |
| 5537 | add_submenu_page( |
| 5538 | "upload.php", |
| 5539 | esc_html__('Media Cleaning', 'folders'), |
| 5540 | esc_html__('Media Cleaning', 'folders'), |
| 5541 | 'manage_options', |
| 5542 | 'folders-media-cleaning', |
| 5543 | [ |
| 5544 | $this, |
| 5545 | 'wcp_folders_media_cleaning', |
| 5546 | ] |
| 5547 | ); |
| 5548 | } |
| 5549 | }//end if |
| 5550 | |
| 5551 | self::check_and_set_post_type(); |
| 5552 | |
| 5553 | $show_menu = get_option("folders_show_in_menu", true); |
| 5554 | if ($show_menu == "on") { |
| 5555 | self::create_menu_for_folders(); |
| 5556 | } |
| 5557 | |
| 5558 | }//end admin_menu() |
| 5559 | |
| 5560 | |
| 5561 | /** |
| 5562 | * Media Cleaner Page |
| 5563 | * |
| 5564 | * @since 1.0.0 |
| 5565 | * @access public |
| 5566 | * @return $html |
| 5567 | */ |
| 5568 | public function wcp_folders_media_cleaning() |
| 5569 | { |
| 5570 | include_once dirname(dirname(__FILE__))."/templates/admin/media-cleaning.php"; |
| 5571 | |
| 5572 | }//end wcp_folders_media_cleaning() |
| 5573 | |
| 5574 | |
| 5575 | /** |
| 5576 | * Recommended plugins Page |
| 5577 | * |
| 5578 | * @since 1.0.0 |
| 5579 | * @access public |
| 5580 | * @return $html |
| 5581 | */ |
| 5582 | public function recommended_plugins() |
| 5583 | { |
| 5584 | include_once dirname(dirname(__FILE__))."/templates/admin/recommended-plugins.php"; |
| 5585 | |
| 5586 | }//end recommended_plugins() |
| 5587 | |
| 5588 | |
| 5589 | /** |
| 5590 | * Folders Upgrade Page |
| 5591 | * |
| 5592 | * @since 1.0.0 |
| 5593 | * @access public |
| 5594 | * @return $html |
| 5595 | */ |
| 5596 | public function wcp_folders_upgrade_or_register() |
| 5597 | { |
| 5598 | self::set_default_values_if_not_exists(); |
| 5599 | include_once dirname(dirname(__FILE__))."/templates/admin/upgrade-to-pro.php"; |
| 5600 | |
| 5601 | }//end wcp_folders_upgrade_or_register() |
| 5602 | |
| 5603 | |
| 5604 | /** |
| 5605 | * Folders Settings Page |
| 5606 | * |
| 5607 | * @since 1.0.0 |
| 5608 | * @access public |
| 5609 | * @return $html |
| 5610 | */ |
| 5611 | public function wcp_folders_settings() |
| 5612 | { |
| 5613 | self::set_default_values_if_not_exists(); |
| 5614 | // Only in Free, Get Folders update confirmation popup |
| 5615 | $is_shown = get_option("folder_update_message"); |
| 5616 | if ($is_shown === false) { |
| 5617 | include_once dirname(dirname(__FILE__))."/templates/admin/update.php"; |
| 5618 | } else { |
| 5619 | $options = get_option('folders_settings'); |
| 5620 | $options = (empty($options) || !is_array($options)) ? [] : $options; |
| 5621 | $post_types = get_post_types(['public' => true], 'objects'); |
| 5622 | $terms_data = []; |
| 5623 | foreach ($post_types as $post_type) { |
| 5624 | if (in_array($post_type->name, $options)) { |
| 5625 | $term = $post_type->name; |
| 5626 | $term = self::get_custom_post_type($term); |
| 5627 | $categories = self::get_terms_hierarchical($term); |
| 5628 | $terms_data[$post_type->name] = $categories; |
| 5629 | } else { |
| 5630 | $terms_data[$post_type->name] = []; |
| 5631 | } |
| 5632 | } |
| 5633 | |
| 5634 | $fonts = self::get_font_list(); |
| 5635 | |
| 5636 | $plugins = new WCP_Folder_Plugins(); |
| 5637 | $plugin_info = $plugins->get_plugin_information(); |
| 5638 | $is_plugin_exists = $plugins->isExists; |
| 5639 | $settingURL = $this->getFolderSettingsURL(); |
| 5640 | $setting_page = filter_input(INPUT_GET, 'setting_page'); |
| 5641 | if (empty($setting_page)) { |
| 5642 | $setting_page = "folder-settings"; |
| 5643 | } |
| 5644 | |
| 5645 | $setting_page = in_array($setting_page, ["folder-settings", "customize-folders", "folders-import", "upgrade-to-pro", "folders-by-user"]) ? $setting_page : "folder-settings"; |
| 5646 | $isInSettings = $this->isFoldersInSettings(); |
| 5647 | |
| 5648 | include_once dirname(dirname(__FILE__))."/templates/admin/general-settings.php"; |
| 5649 | |
| 5650 | $option = get_option("folder_intro_box"); |
| 5651 | if ($option == "show") { |
| 5652 | include_once dirname(dirname(__FILE__))."/templates/admin/folder-popup.php"; |
| 5653 | } |
| 5654 | }//end if |
| 5655 | |
| 5656 | }//end wcp_folders_settings() |
| 5657 | |
| 5658 | |
| 5659 | /** |
| 5660 | * Font List |
| 5661 | * |
| 5662 | * @since 1.0.0 |
| 5663 | * @access public |
| 5664 | * @return $fonts |
| 5665 | */ |
| 5666 | public static function get_font_list() |
| 5667 | { |
| 5668 | return [ |
| 5669 | // System fonts. |
| 5670 | 'Default' => 'Default', |
| 5671 | "System Stack" => 'Default', |
| 5672 | 'Arial' => 'Default', |
| 5673 | 'Tahoma' => 'Default', |
| 5674 | 'Verdana' => 'Default', |
| 5675 | 'Helvetica' => 'Default', |
| 5676 | 'Times New Roman' => 'Default', |
| 5677 | 'Trebuchet MS' => 'Default', |
| 5678 | 'Georgia' => 'Default', |
| 5679 | |
| 5680 | // Google Fonts (last update: 23/10/2018). |
| 5681 | 'ABeeZee' => 'Google Fonts', |
| 5682 | 'Abel' => 'Google Fonts', |
| 5683 | 'Abhaya Libre' => 'Google Fonts', |
| 5684 | 'Abril Fatface' => 'Google Fonts', |
| 5685 | 'Aclonica' => 'Google Fonts', |
| 5686 | 'Acme' => 'Google Fonts', |
| 5687 | 'Actor' => 'Google Fonts', |
| 5688 | 'Adamina' => 'Google Fonts', |
| 5689 | 'Advent Pro' => 'Google Fonts', |
| 5690 | 'Aguafina Script' => 'Google Fonts', |
| 5691 | 'Akronim' => 'Google Fonts', |
| 5692 | 'Aladin' => 'Google Fonts', |
| 5693 | 'Aldrich' => 'Google Fonts', |
| 5694 | 'Alef' => 'Google Fonts', |
| 5695 | 'Alef Hebrew' => 'Google Fonts', |
| 5696 | // Hack for Google Early Access. |
| 5697 | 'Alegreya' => 'Google Fonts', |
| 5698 | 'Alegreya SC' => 'Google Fonts', |
| 5699 | 'Alegreya Sans' => 'Google Fonts', |
| 5700 | 'Alegreya Sans SC' => 'Google Fonts', |
| 5701 | 'Alex Brush' => 'Google Fonts', |
| 5702 | 'Alfa Slab One' => 'Google Fonts', |
| 5703 | 'Alice' => 'Google Fonts', |
| 5704 | 'Alike' => 'Google Fonts', |
| 5705 | 'Alike Angular' => 'Google Fonts', |
| 5706 | 'Allan' => 'Google Fonts', |
| 5707 | 'Allerta' => 'Google Fonts', |
| 5708 | 'Allerta Stencil' => 'Google Fonts', |
| 5709 | 'Allura' => 'Google Fonts', |
| 5710 | 'Almendra' => 'Google Fonts', |
| 5711 | 'Almendra Display' => 'Google Fonts', |
| 5712 | 'Almendra SC' => 'Google Fonts', |
| 5713 | 'Amarante' => 'Google Fonts', |
| 5714 | 'Amaranth' => 'Google Fonts', |
| 5715 | 'Amatic SC' => 'Google Fonts', |
| 5716 | 'Amethysta' => 'Google Fonts', |
| 5717 | 'Amiko' => 'Google Fonts', |
| 5718 | 'Amiri' => 'Google Fonts', |
| 5719 | 'Amita' => 'Google Fonts', |
| 5720 | 'Anaheim' => 'Google Fonts', |
| 5721 | 'Andada' => 'Google Fonts', |
| 5722 | 'Andika' => 'Google Fonts', |
| 5723 | 'Angkor' => 'Google Fonts', |
| 5724 | 'Annie Use Your Telescope' => 'Google Fonts', |
| 5725 | 'Anonymous Pro' => 'Google Fonts', |
| 5726 | 'Antic' => 'Google Fonts', |
| 5727 | 'Antic Didone' => 'Google Fonts', |
| 5728 | 'Antic Slab' => 'Google Fonts', |
| 5729 | 'Anton' => 'Google Fonts', |
| 5730 | 'Arapey' => 'Google Fonts', |
| 5731 | 'Arbutus' => 'Google Fonts', |
| 5732 | 'Arbutus Slab' => 'Google Fonts', |
| 5733 | 'Architects Daughter' => 'Google Fonts', |
| 5734 | 'Archivo' => 'Google Fonts', |
| 5735 | 'Archivo Black' => 'Google Fonts', |
| 5736 | 'Archivo Narrow' => 'Google Fonts', |
| 5737 | 'Aref Ruqaa' => 'Google Fonts', |
| 5738 | 'Arima Madurai' => 'Google Fonts', |
| 5739 | 'Arimo' => 'Google Fonts', |
| 5740 | 'Arizonia' => 'Google Fonts', |
| 5741 | 'Armata' => 'Google Fonts', |
| 5742 | 'Arsenal' => 'Google Fonts', |
| 5743 | 'Artifika' => 'Google Fonts', |
| 5744 | 'Arvo' => 'Google Fonts', |
| 5745 | 'Arya' => 'Google Fonts', |
| 5746 | 'Asap' => 'Google Fonts', |
| 5747 | 'Asap Condensed' => 'Google Fonts', |
| 5748 | 'Asar' => 'Google Fonts', |
| 5749 | 'Asset' => 'Google Fonts', |
| 5750 | 'Assistant' => 'Google Fonts', |
| 5751 | 'Astloch' => 'Google Fonts', |
| 5752 | 'Asul' => 'Google Fonts', |
| 5753 | 'Athiti' => 'Google Fonts', |
| 5754 | 'Atma' => 'Google Fonts', |
| 5755 | 'Atomic Age' => 'Google Fonts', |
| 5756 | 'Aubrey' => 'Google Fonts', |
| 5757 | 'Audiowide' => 'Google Fonts', |
| 5758 | 'Autour One' => 'Google Fonts', |
| 5759 | 'Average' => 'Google Fonts', |
| 5760 | 'Average Sans' => 'Google Fonts', |
| 5761 | 'Averia Gruesa Libre' => 'Google Fonts', |
| 5762 | 'Averia Libre' => 'Google Fonts', |
| 5763 | 'Averia Sans Libre' => 'Google Fonts', |
| 5764 | 'Averia Serif Libre' => 'Google Fonts', |
| 5765 | 'Bad Script' => 'Google Fonts', |
| 5766 | 'Bahiana' => 'Google Fonts', |
| 5767 | 'Bai Jamjuree' => 'Google Fonts', |
| 5768 | 'Baloo' => 'Google Fonts', |
| 5769 | 'Baloo Bhai' => 'Google Fonts', |
| 5770 | 'Baloo Bhaijaan' => 'Google Fonts', |
| 5771 | 'Baloo Bhaina' => 'Google Fonts', |
| 5772 | 'Baloo Chettan' => 'Google Fonts', |
| 5773 | 'Baloo Da' => 'Google Fonts', |
| 5774 | 'Baloo Paaji' => 'Google Fonts', |
| 5775 | 'Baloo Tamma' => 'Google Fonts', |
| 5776 | 'Baloo Tammudu' => 'Google Fonts', |
| 5777 | 'Baloo Thambi' => 'Google Fonts', |
| 5778 | 'Balthazar' => 'Google Fonts', |
| 5779 | 'Bangers' => 'Google Fonts', |
| 5780 | 'Barlow' => 'Google Fonts', |
| 5781 | 'Barlow Condensed' => 'Google Fonts', |
| 5782 | 'Barlow Semi Condensed' => 'Google Fonts', |
| 5783 | 'Barrio' => 'Google Fonts', |
| 5784 | 'Basic' => 'Google Fonts', |
| 5785 | 'Battambang' => 'Google Fonts', |
| 5786 | 'Baumans' => 'Google Fonts', |
| 5787 | 'Bayon' => 'Google Fonts', |
| 5788 | 'Belgrano' => 'Google Fonts', |
| 5789 | 'Bellefair' => 'Google Fonts', |
| 5790 | 'Belleza' => 'Google Fonts', |
| 5791 | 'BenchNine' => 'Google Fonts', |
| 5792 | 'Bentham' => 'Google Fonts', |
| 5793 | 'Berkshire Swash' => 'Google Fonts', |
| 5794 | 'Bevan' => 'Google Fonts', |
| 5795 | 'Bigelow Rules' => 'Google Fonts', |
| 5796 | 'Bigshot One' => 'Google Fonts', |
| 5797 | 'Bilbo' => 'Google Fonts', |
| 5798 | 'Bilbo Swash Caps' => 'Google Fonts', |
| 5799 | 'BioRhyme' => 'Google Fonts', |
| 5800 | 'BioRhyme Expanded' => 'Google Fonts', |
| 5801 | 'Biryani' => 'Google Fonts', |
| 5802 | 'Bitter' => 'Google Fonts', |
| 5803 | 'Black And White Picture' => 'Google Fonts', |
| 5804 | 'Black Han Sans' => 'Google Fonts', |
| 5805 | 'Black Ops One' => 'Google Fonts', |
| 5806 | 'Bokor' => 'Google Fonts', |
| 5807 | 'Bonbon' => 'Google Fonts', |
| 5808 | 'Boogaloo' => 'Google Fonts', |
| 5809 | 'Bowlby One' => 'Google Fonts', |
| 5810 | 'Bowlby One SC' => 'Google Fonts', |
| 5811 | 'Brawler' => 'Google Fonts', |
| 5812 | 'Bree Serif' => 'Google Fonts', |
| 5813 | 'Bubblegum Sans' => 'Google Fonts', |
| 5814 | 'Bubbler One' => 'Google Fonts', |
| 5815 | 'Buda' => 'Google Fonts', |
| 5816 | 'Buenard' => 'Google Fonts', |
| 5817 | 'Bungee' => 'Google Fonts', |
| 5818 | 'Bungee Hairline' => 'Google Fonts', |
| 5819 | 'Bungee Inline' => 'Google Fonts', |
| 5820 | 'Bungee Outline' => 'Google Fonts', |
| 5821 | 'Bungee Shade' => 'Google Fonts', |
| 5822 | 'Butcherman' => 'Google Fonts', |
| 5823 | 'Butterfly Kids' => 'Google Fonts', |
| 5824 | 'Cabin' => 'Google Fonts', |
| 5825 | 'Cabin Condensed' => 'Google Fonts', |
| 5826 | 'Cabin Sketch' => 'Google Fonts', |
| 5827 | 'Caesar Dressing' => 'Google Fonts', |
| 5828 | 'Cagliostro' => 'Google Fonts', |
| 5829 | 'Cairo' => 'Google Fonts', |
| 5830 | 'Calligraffitti' => 'Google Fonts', |
| 5831 | 'Cambay' => 'Google Fonts', |
| 5832 | 'Cambo' => 'Google Fonts', |
| 5833 | 'Candal' => 'Google Fonts', |
| 5834 | 'Cantarell' => 'Google Fonts', |
| 5835 | 'Cantata One' => 'Google Fonts', |
| 5836 | 'Cantora One' => 'Google Fonts', |
| 5837 | 'Capriola' => 'Google Fonts', |
| 5838 | 'Cardo' => 'Google Fonts', |
| 5839 | 'Carme' => 'Google Fonts', |
| 5840 | 'Carrois Gothic' => 'Google Fonts', |
| 5841 | 'Carrois Gothic SC' => 'Google Fonts', |
| 5842 | 'Carter One' => 'Google Fonts', |
| 5843 | 'Catamaran' => 'Google Fonts', |
| 5844 | 'Caudex' => 'Google Fonts', |
| 5845 | 'Caveat' => 'Google Fonts', |
| 5846 | 'Caveat Brush' => 'Google Fonts', |
| 5847 | 'Cedarville Cursive' => 'Google Fonts', |
| 5848 | 'Ceviche One' => 'Google Fonts', |
| 5849 | 'Chakra Petch' => 'Google Fonts', |
| 5850 | 'Changa' => 'Google Fonts', |
| 5851 | 'Changa One' => 'Google Fonts', |
| 5852 | 'Chango' => 'Google Fonts', |
| 5853 | 'Charmonman' => 'Google Fonts', |
| 5854 | 'Chathura' => 'Google Fonts', |
| 5855 | 'Chau Philomene One' => 'Google Fonts', |
| 5856 | 'Chela One' => 'Google Fonts', |
| 5857 | 'Chelsea Market' => 'Google Fonts', |
| 5858 | 'Chenla' => 'Google Fonts', |
| 5859 | 'Cherry Cream Soda' => 'Google Fonts', |
| 5860 | 'Cherry Swash' => 'Google Fonts', |
| 5861 | 'Chewy' => 'Google Fonts', |
| 5862 | 'Chicle' => 'Google Fonts', |
| 5863 | 'Chivo' => 'Google Fonts', |
| 5864 | 'Chonburi' => 'Google Fonts', |
| 5865 | 'Cinzel' => 'Google Fonts', |
| 5866 | 'Cinzel Decorative' => 'Google Fonts', |
| 5867 | 'Clicker Script' => 'Google Fonts', |
| 5868 | 'Coda' => 'Google Fonts', |
| 5869 | 'Coda Caption' => 'Google Fonts', |
| 5870 | 'Codystar' => 'Google Fonts', |
| 5871 | 'Coiny' => 'Google Fonts', |
| 5872 | 'Combo' => 'Google Fonts', |
| 5873 | 'Comfortaa' => 'Google Fonts', |
| 5874 | 'Coming Soon' => 'Google Fonts', |
| 5875 | 'Concert One' => 'Google Fonts', |
| 5876 | 'Condiment' => 'Google Fonts', |
| 5877 | 'Content' => 'Google Fonts', |
| 5878 | 'Contrail One' => 'Google Fonts', |
| 5879 | 'Convergence' => 'Google Fonts', |
| 5880 | 'Cookie' => 'Google Fonts', |
| 5881 | 'Copse' => 'Google Fonts', |
| 5882 | 'Corben' => 'Google Fonts', |
| 5883 | 'Cormorant' => 'Google Fonts', |
| 5884 | 'Cormorant Garamond' => 'Google Fonts', |
| 5885 | 'Cormorant Infant' => 'Google Fonts', |
| 5886 | 'Cormorant SC' => 'Google Fonts', |
| 5887 | 'Cormorant Unicase' => 'Google Fonts', |
| 5888 | 'Cormorant Upright' => 'Google Fonts', |
| 5889 | 'Courgette' => 'Google Fonts', |
| 5890 | 'Cousine' => 'Google Fonts', |
| 5891 | 'Coustard' => 'Google Fonts', |
| 5892 | 'Covered By Your Grace' => 'Google Fonts', |
| 5893 | 'Crafty Girls' => 'Google Fonts', |
| 5894 | 'Creepster' => 'Google Fonts', |
| 5895 | 'Crete Round' => 'Google Fonts', |
| 5896 | 'Crimson Text' => 'Google Fonts', |
| 5897 | 'Croissant One' => 'Google Fonts', |
| 5898 | 'Crushed' => 'Google Fonts', |
| 5899 | 'Cuprum' => 'Google Fonts', |
| 5900 | 'Cute Font' => 'Google Fonts', |
| 5901 | 'Cutive' => 'Google Fonts', |
| 5902 | 'Cutive Mono' => 'Google Fonts', |
| 5903 | 'Damion' => 'Google Fonts', |
| 5904 | 'Dancing Script' => 'Google Fonts', |
| 5905 | 'Dangrek' => 'Google Fonts', |
| 5906 | 'David Libre' => 'Google Fonts', |
| 5907 | 'Dawning of a New Day' => 'Google Fonts', |
| 5908 | 'Days One' => 'Google Fonts', |
| 5909 | 'Dekko' => 'Google Fonts', |
| 5910 | 'Delius' => 'Google Fonts', |
| 5911 | 'Delius Swash Caps' => 'Google Fonts', |
| 5912 | 'Delius Unicase' => 'Google Fonts', |
| 5913 | 'Della Respira' => 'Google Fonts', |
| 5914 | 'Denk One' => 'Google Fonts', |
| 5915 | 'Devonshire' => 'Google Fonts', |
| 5916 | 'Dhurjati' => 'Google Fonts', |
| 5917 | 'Didact Gothic' => 'Google Fonts', |
| 5918 | 'Diplomata' => 'Google Fonts', |
| 5919 | 'Diplomata SC' => 'Google Fonts', |
| 5920 | 'Do Hyeon' => 'Google Fonts', |
| 5921 | 'Dokdo' => 'Google Fonts', |
| 5922 | 'Domine' => 'Google Fonts', |
| 5923 | 'Donegal One' => 'Google Fonts', |
| 5924 | 'Doppio One' => 'Google Fonts', |
| 5925 | 'Dorsa' => 'Google Fonts', |
| 5926 | 'Dosis' => 'Google Fonts', |
| 5927 | 'Dr Sugiyama' => 'Google Fonts', |
| 5928 | 'Droid Arabic Kufi' => 'Google Fonts', |
| 5929 | // Hack for Google Early Access. |
| 5930 | 'Droid Arabic Naskh' => 'Google Fonts', |
| 5931 | // Hack for Google Early Access. |
| 5932 | 'Duru Sans' => 'Google Fonts', |
| 5933 | 'Dynalight' => 'Google Fonts', |
| 5934 | 'EB Garamond' => 'Google Fonts', |
| 5935 | 'Eagle Lake' => 'Google Fonts', |
| 5936 | 'East Sea Dokdo' => 'Google Fonts', |
| 5937 | 'Eater' => 'Google Fonts', |
| 5938 | 'Economica' => 'Google Fonts', |
| 5939 | 'Eczar' => 'Google Fonts', |
| 5940 | 'El Messiri' => 'Google Fonts', |
| 5941 | 'Electrolize' => 'Google Fonts', |
| 5942 | 'Elsie' => 'Google Fonts', |
| 5943 | 'Elsie Swash Caps' => 'Google Fonts', |
| 5944 | 'Emblema One' => 'Google Fonts', |
| 5945 | 'Emilys Candy' => 'Google Fonts', |
| 5946 | 'Encode Sans' => 'Google Fonts', |
| 5947 | 'Encode Sans Condensed' => 'Google Fonts', |
| 5948 | 'Encode Sans Expanded' => 'Google Fonts', |
| 5949 | 'Encode Sans Semi Condensed' => 'Google Fonts', |
| 5950 | 'Encode Sans Semi Expanded' => 'Google Fonts', |
| 5951 | 'Engagement' => 'Google Fonts', |
| 5952 | 'Englebert' => 'Google Fonts', |
| 5953 | 'Enriqueta' => 'Google Fonts', |
| 5954 | 'Erica One' => 'Google Fonts', |
| 5955 | 'Esteban' => 'Google Fonts', |
| 5956 | 'Euphoria Script' => 'Google Fonts', |
| 5957 | 'Ewert' => 'Google Fonts', |
| 5958 | 'Exo' => 'Google Fonts', |
| 5959 | 'Exo 2' => 'Google Fonts', |
| 5960 | 'Expletus Sans' => 'Google Fonts', |
| 5961 | 'Fahkwang' => 'Google Fonts', |
| 5962 | 'Fanwood Text' => 'Google Fonts', |
| 5963 | 'Farsan' => 'Google Fonts', |
| 5964 | 'Fascinate' => 'Google Fonts', |
| 5965 | 'Fascinate Inline' => 'Google Fonts', |
| 5966 | 'Faster One' => 'Google Fonts', |
| 5967 | 'Fasthand' => 'Google Fonts', |
| 5968 | 'Fauna One' => 'Google Fonts', |
| 5969 | 'Faustina' => 'Google Fonts', |
| 5970 | 'Federant' => 'Google Fonts', |
| 5971 | 'Federo' => 'Google Fonts', |
| 5972 | 'Felipa' => 'Google Fonts', |
| 5973 | 'Fenix' => 'Google Fonts', |
| 5974 | 'Finger Paint' => 'Google Fonts', |
| 5975 | 'Fira Mono' => 'Google Fonts', |
| 5976 | 'Fira Sans' => 'Google Fonts', |
| 5977 | 'Fira Sans Condensed' => 'Google Fonts', |
| 5978 | 'Fira Sans Extra Condensed' => 'Google Fonts', |
| 5979 | 'Fjalla One' => 'Google Fonts', |
| 5980 | 'Fjord One' => 'Google Fonts', |
| 5981 | 'Flamenco' => 'Google Fonts', |
| 5982 | 'Flavors' => 'Google Fonts', |
| 5983 | 'Fondamento' => 'Google Fonts', |
| 5984 | 'Fontdiner Swanky' => 'Google Fonts', |
| 5985 | 'Forum' => 'Google Fonts', |
| 5986 | 'Francois One' => 'Google Fonts', |
| 5987 | 'Frank Ruhl Libre' => 'Google Fonts', |
| 5988 | 'Freckle Face' => 'Google Fonts', |
| 5989 | 'Fredericka the Great' => 'Google Fonts', |
| 5990 | 'Fredoka One' => 'Google Fonts', |
| 5991 | 'Freehand' => 'Google Fonts', |
| 5992 | 'Fresca' => 'Google Fonts', |
| 5993 | 'Frijole' => 'Google Fonts', |
| 5994 | 'Fruktur' => 'Google Fonts', |
| 5995 | 'Fugaz One' => 'Google Fonts', |
| 5996 | 'GFS Didot' => 'Google Fonts', |
| 5997 | 'GFS Neohellenic' => 'Google Fonts', |
| 5998 | 'Gabriela' => 'Google Fonts', |
| 5999 | 'Gaegu' => 'Google Fonts', |
| 6000 | 'Gafata' => 'Google Fonts', |
| 6001 | 'Galada' => 'Google Fonts', |
| 6002 | 'Galdeano' => 'Google Fonts', |
| 6003 | 'Galindo' => 'Google Fonts', |
| 6004 | 'Gamja Flower' => 'Google Fonts', |
| 6005 | 'Gentium Basic' => 'Google Fonts', |
| 6006 | 'Gentium Book Basic' => 'Google Fonts', |
| 6007 | 'Geo' => 'Google Fonts', |
| 6008 | 'Geostar' => 'Google Fonts', |
| 6009 | 'Geostar Fill' => 'Google Fonts', |
| 6010 | 'Germania One' => 'Google Fonts', |
| 6011 | 'Gidugu' => 'Google Fonts', |
| 6012 | 'Gilda Display' => 'Google Fonts', |
| 6013 | 'Give You Glory' => 'Google Fonts', |
| 6014 | 'Glass Antiqua' => 'Google Fonts', |
| 6015 | 'Glegoo' => 'Google Fonts', |
| 6016 | 'Gloria Hallelujah' => 'Google Fonts', |
| 6017 | 'Goblin One' => 'Google Fonts', |
| 6018 | 'Gochi Hand' => 'Google Fonts', |
| 6019 | 'Gorditas' => 'Google Fonts', |
| 6020 | 'Gothic A1' => 'Google Fonts', |
| 6021 | 'Goudy Bookletter 1911' => 'Google Fonts', |
| 6022 | 'Graduate' => 'Google Fonts', |
| 6023 | 'Grand Hotel' => 'Google Fonts', |
| 6024 | 'Gravitas One' => 'Google Fonts', |
| 6025 | 'Great Vibes' => 'Google Fonts', |
| 6026 | 'Griffy' => 'Google Fonts', |
| 6027 | 'Gruppo' => 'Google Fonts', |
| 6028 | 'Gudea' => 'Google Fonts', |
| 6029 | 'Gugi' => 'Google Fonts', |
| 6030 | 'Gurajada' => 'Google Fonts', |
| 6031 | 'Habibi' => 'Google Fonts', |
| 6032 | 'Halant' => 'Google Fonts', |
| 6033 | 'Hammersmith One' => 'Google Fonts', |
| 6034 | 'Hanalei' => 'Google Fonts', |
| 6035 | 'Hanalei Fill' => 'Google Fonts', |
| 6036 | 'Handlee' => 'Google Fonts', |
| 6037 | 'Hanuman' => 'Google Fonts', |
| 6038 | 'Happy Monkey' => 'Google Fonts', |
| 6039 | 'Harmattan' => 'Google Fonts', |
| 6040 | 'Headland One' => 'Google Fonts', |
| 6041 | 'Heebo' => 'Google Fonts', |
| 6042 | 'Henny Penny' => 'Google Fonts', |
| 6043 | 'Herr Von Muellerhoff' => 'Google Fonts', |
| 6044 | 'Hi Melody' => 'Google Fonts', |
| 6045 | 'Hind' => 'Google Fonts', |
| 6046 | 'Hind Guntur' => 'Google Fonts', |
| 6047 | 'Hind Madurai' => 'Google Fonts', |
| 6048 | 'Hind Siliguri' => 'Google Fonts', |
| 6049 | 'Hind Vadodara' => 'Google Fonts', |
| 6050 | 'Holtwood One SC' => 'Google Fonts', |
| 6051 | 'Homemade Apple' => 'Google Fonts', |
| 6052 | 'Homenaje' => 'Google Fonts', |
| 6053 | 'IBM Plex Mono' => 'Google Fonts', |
| 6054 | 'IBM Plex Sans' => 'Google Fonts', |
| 6055 | 'IBM Plex Sans Condensed' => 'Google Fonts', |
| 6056 | 'IBM Plex Serif' => 'Google Fonts', |
| 6057 | 'IM Fell DW Pica' => 'Google Fonts', |
| 6058 | 'IM Fell DW Pica SC' => 'Google Fonts', |
| 6059 | 'IM Fell Double Pica' => 'Google Fonts', |
| 6060 | 'IM Fell Double Pica SC' => 'Google Fonts', |
| 6061 | 'IM Fell English' => 'Google Fonts', |
| 6062 | 'IM Fell English SC' => 'Google Fonts', |
| 6063 | 'IM Fell French Canon' => 'Google Fonts', |
| 6064 | 'IM Fell French Canon SC' => 'Google Fonts', |
| 6065 | 'IM Fell Great Primer' => 'Google Fonts', |
| 6066 | 'IM Fell Great Primer SC' => 'Google Fonts', |
| 6067 | 'Iceberg' => 'Google Fonts', |
| 6068 | 'Iceland' => 'Google Fonts', |
| 6069 | 'Imprima' => 'Google Fonts', |
| 6070 | 'Inconsolata' => 'Google Fonts', |
| 6071 | 'Inder' => 'Google Fonts', |
| 6072 | 'Indie Flower' => 'Google Fonts', |
| 6073 | 'Inika' => 'Google Fonts', |
| 6074 | 'Inknut Antiqua' => 'Google Fonts', |
| 6075 | 'Irish Grover' => 'Google Fonts', |
| 6076 | 'Istok Web' => 'Google Fonts', |
| 6077 | 'Italiana' => 'Google Fonts', |
| 6078 | 'Italianno' => 'Google Fonts', |
| 6079 | 'Itim' => 'Google Fonts', |
| 6080 | 'Jacques Francois' => 'Google Fonts', |
| 6081 | 'Jacques Francois Shadow' => 'Google Fonts', |
| 6082 | 'Jaldi' => 'Google Fonts', |
| 6083 | 'Jim Nightshade' => 'Google Fonts', |
| 6084 | 'Jockey One' => 'Google Fonts', |
| 6085 | 'Jolly Lodger' => 'Google Fonts', |
| 6086 | 'Jomhuria' => 'Google Fonts', |
| 6087 | 'Josefin Sans' => 'Google Fonts', |
| 6088 | 'Josefin Slab' => 'Google Fonts', |
| 6089 | 'Joti One' => 'Google Fonts', |
| 6090 | 'Jua' => 'Google Fonts', |
| 6091 | 'Judson' => 'Google Fonts', |
| 6092 | 'Julee' => 'Google Fonts', |
| 6093 | 'Julius Sans One' => 'Google Fonts', |
| 6094 | 'Junge' => 'Google Fonts', |
| 6095 | 'Jura' => 'Google Fonts', |
| 6096 | 'Just Another Hand' => 'Google Fonts', |
| 6097 | 'Just Me Again Down Here' => 'Google Fonts', |
| 6098 | 'K2D' => 'Google Fonts', |
| 6099 | 'Kadwa' => 'Google Fonts', |
| 6100 | 'Kalam' => 'Google Fonts', |
| 6101 | 'Kameron' => 'Google Fonts', |
| 6102 | 'Kanit' => 'Google Fonts', |
| 6103 | 'Kantumruy' => 'Google Fonts', |
| 6104 | 'Karla' => 'Google Fonts', |
| 6105 | 'Karma' => 'Google Fonts', |
| 6106 | 'Katibeh' => 'Google Fonts', |
| 6107 | 'Kaushan Script' => 'Google Fonts', |
| 6108 | 'Kavivanar' => 'Google Fonts', |
| 6109 | 'Kavoon' => 'Google Fonts', |
| 6110 | 'Kdam Thmor' => 'Google Fonts', |
| 6111 | 'Keania One' => 'Google Fonts', |
| 6112 | 'Kelly Slab' => 'Google Fonts', |
| 6113 | 'Kenia' => 'Google Fonts', |
| 6114 | 'Khand' => 'Google Fonts', |
| 6115 | 'Khmer' => 'Google Fonts', |
| 6116 | 'Khula' => 'Google Fonts', |
| 6117 | 'Kirang Haerang' => 'Google Fonts', |
| 6118 | 'Kite One' => 'Google Fonts', |
| 6119 | 'Knewave' => 'Google Fonts', |
| 6120 | 'KoHo' => 'Google Fonts', |
| 6121 | 'Kodchasan' => 'Google Fonts', |
| 6122 | 'Kosugi' => 'Google Fonts', |
| 6123 | 'Kosugi Maru' => 'Google Fonts', |
| 6124 | 'Kotta One' => 'Google Fonts', |
| 6125 | 'Koulen' => 'Google Fonts', |
| 6126 | 'Kranky' => 'Google Fonts', |
| 6127 | 'Kreon' => 'Google Fonts', |
| 6128 | 'Kristi' => 'Google Fonts', |
| 6129 | 'Krona One' => 'Google Fonts', |
| 6130 | 'Krub' => 'Google Fonts', |
| 6131 | 'Kumar One' => 'Google Fonts', |
| 6132 | 'Kumar One Outline' => 'Google Fonts', |
| 6133 | 'Kurale' => 'Google Fonts', |
| 6134 | 'La Belle Aurore' => 'Google Fonts', |
| 6135 | 'Laila' => 'Google Fonts', |
| 6136 | 'Lakki Reddy' => 'Google Fonts', |
| 6137 | 'Lalezar' => 'Google Fonts', |
| 6138 | 'Lancelot' => 'Google Fonts', |
| 6139 | 'Lateef' => 'Google Fonts', |
| 6140 | 'Lato' => 'Google Fonts', |
| 6141 | 'League Script' => 'Google Fonts', |
| 6142 | 'Leckerli One' => 'Google Fonts', |
| 6143 | 'Ledger' => 'Google Fonts', |
| 6144 | 'Lekton' => 'Google Fonts', |
| 6145 | 'Lemon' => 'Google Fonts', |
| 6146 | 'Lemonada' => 'Google Fonts', |
| 6147 | 'Libre Barcode 128' => 'Google Fonts', |
| 6148 | 'Libre Barcode 128 Text' => 'Google Fonts', |
| 6149 | 'Libre Barcode 39' => 'Google Fonts', |
| 6150 | 'Libre Barcode 39 Extended' => 'Google Fonts', |
| 6151 | 'Libre Barcode 39 Extended Text' => 'Google Fonts', |
| 6152 | 'Libre Barcode 39 Text' => 'Google Fonts', |
| 6153 | 'Libre Baskerville' => 'Google Fonts', |
| 6154 | 'Libre Franklin' => 'Google Fonts', |
| 6155 | 'Life Savers' => 'Google Fonts', |
| 6156 | 'Lilita One' => 'Google Fonts', |
| 6157 | 'Lily Script One' => 'Google Fonts', |
| 6158 | 'Limelight' => 'Google Fonts', |
| 6159 | 'Linden Hill' => 'Google Fonts', |
| 6160 | 'Lobster' => 'Google Fonts', |
| 6161 | 'Lobster Two' => 'Google Fonts', |
| 6162 | 'Londrina Outline' => 'Google Fonts', |
| 6163 | 'Londrina Shadow' => 'Google Fonts', |
| 6164 | 'Londrina Sketch' => 'Google Fonts', |
| 6165 | 'Londrina Solid' => 'Google Fonts', |
| 6166 | 'Lora' => 'Google Fonts', |
| 6167 | 'Love Ya Like A Sister' => 'Google Fonts', |
| 6168 | 'Loved by the King' => 'Google Fonts', |
| 6169 | 'Lovers Quarrel' => 'Google Fonts', |
| 6170 | 'Luckiest Guy' => 'Google Fonts', |
| 6171 | 'Lusitana' => 'Google Fonts', |
| 6172 | 'Lustria' => 'Google Fonts', |
| 6173 | 'M PLUS 1p' => 'Google Fonts', |
| 6174 | 'M PLUS Rounded 1c' => 'Google Fonts', |
| 6175 | 'Macondo' => 'Google Fonts', |
| 6176 | 'Macondo Swash Caps' => 'Google Fonts', |
| 6177 | 'Mada' => 'Google Fonts', |
| 6178 | 'Magra' => 'Google Fonts', |
| 6179 | 'Maiden Orange' => 'Google Fonts', |
| 6180 | 'Maitree' => 'Google Fonts', |
| 6181 | 'Mako' => 'Google Fonts', |
| 6182 | 'Mali' => 'Google Fonts', |
| 6183 | 'Mallanna' => 'Google Fonts', |
| 6184 | 'Mandali' => 'Google Fonts', |
| 6185 | 'Manuale' => 'Google Fonts', |
| 6186 | 'Marcellus' => 'Google Fonts', |
| 6187 | 'Marcellus SC' => 'Google Fonts', |
| 6188 | 'Marck Script' => 'Google Fonts', |
| 6189 | 'Margarine' => 'Google Fonts', |
| 6190 | 'Markazi Text' => 'Google Fonts', |
| 6191 | 'Marko One' => 'Google Fonts', |
| 6192 | 'Marmelad' => 'Google Fonts', |
| 6193 | 'Martel' => 'Google Fonts', |
| 6194 | 'Martel Sans' => 'Google Fonts', |
| 6195 | 'Marvel' => 'Google Fonts', |
| 6196 | 'Mate' => 'Google Fonts', |
| 6197 | 'Mate SC' => 'Google Fonts', |
| 6198 | 'Maven Pro' => 'Google Fonts', |
| 6199 | 'McLaren' => 'Google Fonts', |
| 6200 | 'Meddon' => 'Google Fonts', |
| 6201 | 'MedievalSharp' => 'Google Fonts', |
| 6202 | 'Medula One' => 'Google Fonts', |
| 6203 | 'Meera Inimai' => 'Google Fonts', |
| 6204 | 'Megrim' => 'Google Fonts', |
| 6205 | 'Meie Script' => 'Google Fonts', |
| 6206 | 'Merienda' => 'Google Fonts', |
| 6207 | 'Merienda One' => 'Google Fonts', |
| 6208 | 'Merriweather' => 'Google Fonts', |
| 6209 | 'Merriweather Sans' => 'Google Fonts', |
| 6210 | 'Metal' => 'Google Fonts', |
| 6211 | 'Metal Mania' => 'Google Fonts', |
| 6212 | 'Metamorphous' => 'Google Fonts', |
| 6213 | 'Metrophobic' => 'Google Fonts', |
| 6214 | 'Michroma' => 'Google Fonts', |
| 6215 | 'Milonga' => 'Google Fonts', |
| 6216 | 'Miltonian' => 'Google Fonts', |
| 6217 | 'Miltonian Tattoo' => 'Google Fonts', |
| 6218 | 'Mina' => 'Google Fonts', |
| 6219 | 'Miniver' => 'Google Fonts', |
| 6220 | 'Miriam Libre' => 'Google Fonts', |
| 6221 | 'Mirza' => 'Google Fonts', |
| 6222 | 'Miss Fajardose' => 'Google Fonts', |
| 6223 | 'Mitr' => 'Google Fonts', |
| 6224 | 'Modak' => 'Google Fonts', |
| 6225 | 'Modern Antiqua' => 'Google Fonts', |
| 6226 | 'Mogra' => 'Google Fonts', |
| 6227 | 'Molengo' => 'Google Fonts', |
| 6228 | 'Molle' => 'Google Fonts', |
| 6229 | 'Monda' => 'Google Fonts', |
| 6230 | 'Monofett' => 'Google Fonts', |
| 6231 | 'Monoton' => 'Google Fonts', |
| 6232 | 'Monsieur La Doulaise' => 'Google Fonts', |
| 6233 | 'Montaga' => 'Google Fonts', |
| 6234 | 'Montez' => 'Google Fonts', |
| 6235 | 'Montserrat' => 'Google Fonts', |
| 6236 | 'Montserrat Alternates' => 'Google Fonts', |
| 6237 | 'Montserrat Subrayada' => 'Google Fonts', |
| 6238 | 'Moul' => 'Google Fonts', |
| 6239 | 'Moulpali' => 'Google Fonts', |
| 6240 | 'Mountains of Christmas' => 'Google Fonts', |
| 6241 | 'Mouse Memoirs' => 'Google Fonts', |
| 6242 | 'Mr Bedfort' => 'Google Fonts', |
| 6243 | 'Mr Dafoe' => 'Google Fonts', |
| 6244 | 'Mr De Haviland' => 'Google Fonts', |
| 6245 | 'Mrs Saint Delafield' => 'Google Fonts', |
| 6246 | 'Mrs Sheppards' => 'Google Fonts', |
| 6247 | 'Mukta' => 'Google Fonts', |
| 6248 | 'Mukta Mahee' => 'Google Fonts', |
| 6249 | 'Mukta Malar' => 'Google Fonts', |
| 6250 | 'Mukta Vaani' => 'Google Fonts', |
| 6251 | 'Muli' => 'Google Fonts', |
| 6252 | 'Mystery Quest' => 'Google Fonts', |
| 6253 | 'NTR' => 'Google Fonts', |
| 6254 | 'Nanum Brush Script' => 'Google Fonts', |
| 6255 | 'Nanum Gothic' => 'Google Fonts', |
| 6256 | 'Nanum Gothic Coding' => 'Google Fonts', |
| 6257 | 'Nanum Myeongjo' => 'Google Fonts', |
| 6258 | 'Nanum Pen Script' => 'Google Fonts', |
| 6259 | 'Neucha' => 'Google Fonts', |
| 6260 | 'Neuton' => 'Google Fonts', |
| 6261 | 'New Rocker' => 'Google Fonts', |
| 6262 | 'News Cycle' => 'Google Fonts', |
| 6263 | 'Niconne' => 'Google Fonts', |
| 6264 | 'Niramit' => 'Google Fonts', |
| 6265 | 'Nixie One' => 'Google Fonts', |
| 6266 | 'Nobile' => 'Google Fonts', |
| 6267 | 'Nokora' => 'Google Fonts', |
| 6268 | 'Norican' => 'Google Fonts', |
| 6269 | 'Nosifer' => 'Google Fonts', |
| 6270 | 'Notable' => 'Google Fonts', |
| 6271 | 'Nothing You Could Do' => 'Google Fonts', |
| 6272 | 'Noticia Text' => 'Google Fonts', |
| 6273 | 'Noto Kufi Arabic' => 'Google Fonts', |
| 6274 | // Hack for Google Early Access. |
| 6275 | 'Noto Naskh Arabic' => 'Google Fonts', |
| 6276 | // Hack for Google Early Access. |
| 6277 | 'Noto Sans' => 'Google Fonts', |
| 6278 | 'Noto Sans Hebrew' => 'Google Fonts', |
| 6279 | // Hack for Google Early Access. |
| 6280 | 'Noto Sans JP' => 'Google Fonts', |
| 6281 | 'Noto Sans KR' => 'Google Fonts', |
| 6282 | 'Noto Serif' => 'Google Fonts', |
| 6283 | 'Noto Serif JP' => 'Google Fonts', |
| 6284 | 'Noto Serif KR' => 'Google Fonts', |
| 6285 | 'Nova Cut' => 'Google Fonts', |
| 6286 | 'Nova Flat' => 'Google Fonts', |
| 6287 | 'Nova Mono' => 'Google Fonts', |
| 6288 | 'Nova Oval' => 'Google Fonts', |
| 6289 | 'Nova Round' => 'Google Fonts', |
| 6290 | 'Nova Script' => 'Google Fonts', |
| 6291 | 'Nova Slim' => 'Google Fonts', |
| 6292 | 'Nova Square' => 'Google Fonts', |
| 6293 | 'Numans' => 'Google Fonts', |
| 6294 | 'Nunito' => 'Google Fonts', |
| 6295 | 'Nunito Sans' => 'Google Fonts', |
| 6296 | 'Odor Mean Chey' => 'Google Fonts', |
| 6297 | 'Offside' => 'Google Fonts', |
| 6298 | 'Old Standard TT' => 'Google Fonts', |
| 6299 | 'Oldenburg' => 'Google Fonts', |
| 6300 | 'Oleo Script' => 'Google Fonts', |
| 6301 | 'Oleo Script Swash Caps' => 'Google Fonts', |
| 6302 | 'Open Sans' => 'Google Fonts', |
| 6303 | 'Open Sans Condensed' => 'Google Fonts', |
| 6304 | 'Open Sans Hebrew' => 'Google Fonts', |
| 6305 | // Hack for Google Early Access. |
| 6306 | 'Open Sans Hebrew Condensed' => 'Google Fonts', |
| 6307 | // Hack for Google Early Access. |
| 6308 | 'Oranienbaum' => 'Google Fonts', |
| 6309 | 'Orbitron' => 'Google Fonts', |
| 6310 | 'Oregano' => 'Google Fonts', |
| 6311 | 'Orienta' => 'Google Fonts', |
| 6312 | 'Original Surfer' => 'Google Fonts', |
| 6313 | 'Oswald' => 'Google Fonts', |
| 6314 | 'Over the Rainbow' => 'Google Fonts', |
| 6315 | 'Overlock' => 'Google Fonts', |
| 6316 | 'Overlock SC' => 'Google Fonts', |
| 6317 | 'Overpass' => 'Google Fonts', |
| 6318 | 'Overpass Mono' => 'Google Fonts', |
| 6319 | 'Ovo' => 'Google Fonts', |
| 6320 | 'Oxygen' => 'Google Fonts', |
| 6321 | 'Oxygen Mono' => 'Google Fonts', |
| 6322 | 'PT Mono' => 'Google Fonts', |
| 6323 | 'PT Sans' => 'Google Fonts', |
| 6324 | 'PT Sans Caption' => 'Google Fonts', |
| 6325 | 'PT Sans Narrow' => 'Google Fonts', |
| 6326 | 'PT Serif' => 'Google Fonts', |
| 6327 | 'PT Serif Caption' => 'Google Fonts', |
| 6328 | 'Pacifico' => 'Google Fonts', |
| 6329 | 'Padauk' => 'Google Fonts', |
| 6330 | 'Palanquin' => 'Google Fonts', |
| 6331 | 'Palanquin Dark' => 'Google Fonts', |
| 6332 | 'Pangolin' => 'Google Fonts', |
| 6333 | 'Paprika' => 'Google Fonts', |
| 6334 | 'Parisienne' => 'Google Fonts', |
| 6335 | 'Passero One' => 'Google Fonts', |
| 6336 | 'Passion One' => 'Google Fonts', |
| 6337 | 'Pathway Gothic One' => 'Google Fonts', |
| 6338 | 'Patrick Hand' => 'Google Fonts', |
| 6339 | 'Patrick Hand SC' => 'Google Fonts', |
| 6340 | 'Pattaya' => 'Google Fonts', |
| 6341 | 'Patua One' => 'Google Fonts', |
| 6342 | 'Pavanam' => 'Google Fonts', |
| 6343 | 'Paytone One' => 'Google Fonts', |
| 6344 | 'Peddana' => 'Google Fonts', |
| 6345 | 'Peralta' => 'Google Fonts', |
| 6346 | 'Permanent Marker' => 'Google Fonts', |
| 6347 | 'Petit Formal Script' => 'Google Fonts', |
| 6348 | 'Petrona' => 'Google Fonts', |
| 6349 | 'Philosopher' => 'Google Fonts', |
| 6350 | 'Piedra' => 'Google Fonts', |
| 6351 | 'Pinyon Script' => 'Google Fonts', |
| 6352 | 'Pirata One' => 'Google Fonts', |
| 6353 | 'Plaster' => 'Google Fonts', |
| 6354 | 'Play' => 'Google Fonts', |
| 6355 | 'Playball' => 'Google Fonts', |
| 6356 | 'Playfair Display' => 'Google Fonts', |
| 6357 | 'Playfair Display SC' => 'Google Fonts', |
| 6358 | 'Podkova' => 'Google Fonts', |
| 6359 | 'Poiret One' => 'Google Fonts', |
| 6360 | 'Poller One' => 'Google Fonts', |
| 6361 | 'Poly' => 'Google Fonts', |
| 6362 | 'Pompiere' => 'Google Fonts', |
| 6363 | 'Pontano Sans' => 'Google Fonts', |
| 6364 | 'Poor Story' => 'Google Fonts', |
| 6365 | 'Poppins' => 'Google Fonts', |
| 6366 | 'Port Lligat Sans' => 'Google Fonts', |
| 6367 | 'Port Lligat Slab' => 'Google Fonts', |
| 6368 | 'Pragati Narrow' => 'Google Fonts', |
| 6369 | 'Prata' => 'Google Fonts', |
| 6370 | 'Preahvihear' => 'Google Fonts', |
| 6371 | 'Press Start 2P' => 'Google Fonts', |
| 6372 | 'Pridi' => 'Google Fonts', |
| 6373 | 'Princess Sofia' => 'Google Fonts', |
| 6374 | 'Prociono' => 'Google Fonts', |
| 6375 | 'Prompt' => 'Google Fonts', |
| 6376 | 'Prosto One' => 'Google Fonts', |
| 6377 | 'Proza Libre' => 'Google Fonts', |
| 6378 | 'Puritan' => 'Google Fonts', |
| 6379 | 'Purple Purse' => 'Google Fonts', |
| 6380 | 'Quando' => 'Google Fonts', |
| 6381 | 'Quantico' => 'Google Fonts', |
| 6382 | 'Quattrocento' => 'Google Fonts', |
| 6383 | 'Quattrocento Sans' => 'Google Fonts', |
| 6384 | 'Questrial' => 'Google Fonts', |
| 6385 | 'Quicksand' => 'Google Fonts', |
| 6386 | 'Quintessential' => 'Google Fonts', |
| 6387 | 'Qwigley' => 'Google Fonts', |
| 6388 | 'Racing Sans One' => 'Google Fonts', |
| 6389 | 'Radley' => 'Google Fonts', |
| 6390 | 'Rajdhani' => 'Google Fonts', |
| 6391 | 'Rakkas' => 'Google Fonts', |
| 6392 | 'Raleway' => 'Google Fonts', |
| 6393 | 'Raleway Dots' => 'Google Fonts', |
| 6394 | 'Ramabhadra' => 'Google Fonts', |
| 6395 | 'Ramaraja' => 'Google Fonts', |
| 6396 | 'Rambla' => 'Google Fonts', |
| 6397 | 'Rammetto One' => 'Google Fonts', |
| 6398 | 'Ranchers' => 'Google Fonts', |
| 6399 | 'Rancho' => 'Google Fonts', |
| 6400 | 'Ranga' => 'Google Fonts', |
| 6401 | 'Rasa' => 'Google Fonts', |
| 6402 | 'Rationale' => 'Google Fonts', |
| 6403 | 'Ravi Prakash' => 'Google Fonts', |
| 6404 | 'Redressed' => 'Google Fonts', |
| 6405 | 'Reem Kufi' => 'Google Fonts', |
| 6406 | 'Reenie Beanie' => 'Google Fonts', |
| 6407 | 'Revalia' => 'Google Fonts', |
| 6408 | 'Rhodium Libre' => 'Google Fonts', |
| 6409 | 'Ribeye' => 'Google Fonts', |
| 6410 | 'Ribeye Marrow' => 'Google Fonts', |
| 6411 | 'Righteous' => 'Google Fonts', |
| 6412 | 'Risque' => 'Google Fonts', |
| 6413 | 'Roboto' => 'Google Fonts', |
| 6414 | 'Roboto Condensed' => 'Google Fonts', |
| 6415 | 'Roboto Mono' => 'Google Fonts', |
| 6416 | 'Roboto Slab' => 'Google Fonts', |
| 6417 | 'Rochester' => 'Google Fonts', |
| 6418 | 'Rock Salt' => 'Google Fonts', |
| 6419 | 'Rokkitt' => 'Google Fonts', |
| 6420 | 'Romanesco' => 'Google Fonts', |
| 6421 | 'Ropa Sans' => 'Google Fonts', |
| 6422 | 'Rosario' => 'Google Fonts', |
| 6423 | 'Rosarivo' => 'Google Fonts', |
| 6424 | 'Rouge Script' => 'Google Fonts', |
| 6425 | 'Rozha One' => 'Google Fonts', |
| 6426 | 'Rubik' => 'Google Fonts', |
| 6427 | 'Rubik Mono One' => 'Google Fonts', |
| 6428 | 'Ruda' => 'Google Fonts', |
| 6429 | 'Rufina' => 'Google Fonts', |
| 6430 | 'Ruge Boogie' => 'Google Fonts', |
| 6431 | 'Ruluko' => 'Google Fonts', |
| 6432 | 'Rum Raisin' => 'Google Fonts', |
| 6433 | 'Ruslan Display' => 'Google Fonts', |
| 6434 | 'Russo One' => 'Google Fonts', |
| 6435 | 'Ruthie' => 'Google Fonts', |
| 6436 | 'Rye' => 'Google Fonts', |
| 6437 | 'Sacramento' => 'Google Fonts', |
| 6438 | 'Sahitya' => 'Google Fonts', |
| 6439 | 'Sail' => 'Google Fonts', |
| 6440 | 'Saira' => 'Google Fonts', |
| 6441 | 'Saira Condensed' => 'Google Fonts', |
| 6442 | 'Saira Extra Condensed' => 'Google Fonts', |
| 6443 | 'Saira Semi Condensed' => 'Google Fonts', |
| 6444 | 'Salsa' => 'Google Fonts', |
| 6445 | 'Sanchez' => 'Google Fonts', |
| 6446 | 'Sancreek' => 'Google Fonts', |
| 6447 | 'Sansita' => 'Google Fonts', |
| 6448 | 'Sarala' => 'Google Fonts', |
| 6449 | 'Sarina' => 'Google Fonts', |
| 6450 | 'Sarpanch' => 'Google Fonts', |
| 6451 | 'Satisfy' => 'Google Fonts', |
| 6452 | 'Sawarabi Gothic' => 'Google Fonts', |
| 6453 | 'Sawarabi Mincho' => 'Google Fonts', |
| 6454 | 'Scada' => 'Google Fonts', |
| 6455 | 'Scheherazade' => 'Google Fonts', |
| 6456 | 'Schoolbell' => 'Google Fonts', |
| 6457 | 'Scope One' => 'Google Fonts', |
| 6458 | 'Seaweed Script' => 'Google Fonts', |
| 6459 | 'Secular One' => 'Google Fonts', |
| 6460 | 'Sedgwick Ave' => 'Google Fonts', |
| 6461 | 'Sedgwick Ave Display' => 'Google Fonts', |
| 6462 | 'Sevillana' => 'Google Fonts', |
| 6463 | 'Seymour One' => 'Google Fonts', |
| 6464 | 'Shadows Into Light' => 'Google Fonts', |
| 6465 | 'Shadows Into Light Two' => 'Google Fonts', |
| 6466 | 'Shanti' => 'Google Fonts', |
| 6467 | 'Share' => 'Google Fonts', |
| 6468 | 'Share Tech' => 'Google Fonts', |
| 6469 | 'Share Tech Mono' => 'Google Fonts', |
| 6470 | 'Shojumaru' => 'Google Fonts', |
| 6471 | 'Short Stack' => 'Google Fonts', |
| 6472 | 'Shrikhand' => 'Google Fonts', |
| 6473 | 'Siemreap' => 'Google Fonts', |
| 6474 | 'Sigmar One' => 'Google Fonts', |
| 6475 | 'Signika' => 'Google Fonts', |
| 6476 | 'Signika Negative' => 'Google Fonts', |
| 6477 | 'Simonetta' => 'Google Fonts', |
| 6478 | 'Sintony' => 'Google Fonts', |
| 6479 | 'Sirin Stencil' => 'Google Fonts', |
| 6480 | 'Six Caps' => 'Google Fonts', |
| 6481 | 'Skranji' => 'Google Fonts', |
| 6482 | 'Slabo 13px' => 'Google Fonts', |
| 6483 | 'Slabo 27px' => 'Google Fonts', |
| 6484 | 'Slackey' => 'Google Fonts', |
| 6485 | 'Smokum' => 'Google Fonts', |
| 6486 | 'Smythe' => 'Google Fonts', |
| 6487 | 'Sniglet' => 'Google Fonts', |
| 6488 | 'Snippet' => 'Google Fonts', |
| 6489 | 'Snowburst One' => 'Google Fonts', |
| 6490 | 'Sofadi One' => 'Google Fonts', |
| 6491 | 'Sofia' => 'Google Fonts', |
| 6492 | 'Song Myung' => 'Google Fonts', |
| 6493 | 'Sonsie One' => 'Google Fonts', |
| 6494 | 'Sorts Mill Goudy' => 'Google Fonts', |
| 6495 | 'Source Code Pro' => 'Google Fonts', |
| 6496 | 'Source Sans Pro' => 'Google Fonts', |
| 6497 | 'Source Serif Pro' => 'Google Fonts', |
| 6498 | 'Space Mono' => 'Google Fonts', |
| 6499 | 'Special Elite' => 'Google Fonts', |
| 6500 | 'Spectral' => 'Google Fonts', |
| 6501 | 'Spectral SC' => 'Google Fonts', |
| 6502 | 'Spicy Rice' => 'Google Fonts', |
| 6503 | 'Spinnaker' => 'Google Fonts', |
| 6504 | 'Spirax' => 'Google Fonts', |
| 6505 | 'Squada One' => 'Google Fonts', |
| 6506 | 'Sree Krushnadevaraya' => 'Google Fonts', |
| 6507 | 'Sriracha' => 'Google Fonts', |
| 6508 | 'Srisakdi' => 'Google Fonts', |
| 6509 | 'Stalemate' => 'Google Fonts', |
| 6510 | 'Stalinist One' => 'Google Fonts', |
| 6511 | 'Stardos Stencil' => 'Google Fonts', |
| 6512 | 'Stint Ultra Condensed' => 'Google Fonts', |
| 6513 | 'Stint Ultra Expanded' => 'Google Fonts', |
| 6514 | 'Stoke' => 'Google Fonts', |
| 6515 | 'Strait' => 'Google Fonts', |
| 6516 | 'Stylish' => 'Google Fonts', |
| 6517 | 'Sue Ellen Francisco' => 'Google Fonts', |
| 6518 | 'Suez One' => 'Google Fonts', |
| 6519 | 'Sumana' => 'Google Fonts', |
| 6520 | 'Sunflower' => 'Google Fonts', |
| 6521 | 'Sunshiney' => 'Google Fonts', |
| 6522 | 'Supermercado One' => 'Google Fonts', |
| 6523 | 'Sura' => 'Google Fonts', |
| 6524 | 'Suranna' => 'Google Fonts', |
| 6525 | 'Suravaram' => 'Google Fonts', |
| 6526 | 'Suwannaphum' => 'Google Fonts', |
| 6527 | 'Swanky and Moo Moo' => 'Google Fonts', |
| 6528 | 'Syncopate' => 'Google Fonts', |
| 6529 | 'Tajawal' => 'Google Fonts', |
| 6530 | 'Tangerine' => 'Google Fonts', |
| 6531 | 'Taprom' => 'Google Fonts', |
| 6532 | 'Tauri' => 'Google Fonts', |
| 6533 | 'Taviraj' => 'Google Fonts', |
| 6534 | 'Teko' => 'Google Fonts', |
| 6535 | 'Telex' => 'Google Fonts', |
| 6536 | 'Tenali Ramakrishna' => 'Google Fonts', |
| 6537 | 'Tenor Sans' => 'Google Fonts', |
| 6538 | 'Text Me One' => 'Google Fonts', |
| 6539 | 'The Girl Next Door' => 'Google Fonts', |
| 6540 | 'Tienne' => 'Google Fonts', |
| 6541 | 'Tillana' => 'Google Fonts', |
| 6542 | 'Timmana' => 'Google Fonts', |
| 6543 | 'Tinos' => 'Google Fonts', |
| 6544 | 'Titan One' => 'Google Fonts', |
| 6545 | 'Titillium Web' => 'Google Fonts', |
| 6546 | 'Trade Winds' => 'Google Fonts', |
| 6547 | 'Trirong' => 'Google Fonts', |
| 6548 | 'Trocchi' => 'Google Fonts', |
| 6549 | 'Trochut' => 'Google Fonts', |
| 6550 | 'Trykker' => 'Google Fonts', |
| 6551 | 'Tulpen One' => 'Google Fonts', |
| 6552 | 'Ubuntu' => 'Google Fonts', |
| 6553 | 'Ubuntu Condensed' => 'Google Fonts', |
| 6554 | 'Ubuntu Mono' => 'Google Fonts', |
| 6555 | 'Ultra' => 'Google Fonts', |
| 6556 | 'Uncial Antiqua' => 'Google Fonts', |
| 6557 | 'Underdog' => 'Google Fonts', |
| 6558 | 'Unica One' => 'Google Fonts', |
| 6559 | 'UnifrakturCook' => 'Google Fonts', |
| 6560 | 'UnifrakturMaguntia' => 'Google Fonts', |
| 6561 | 'Unkempt' => 'Google Fonts', |
| 6562 | 'Unlock' => 'Google Fonts', |
| 6563 | 'Unna' => 'Google Fonts', |
| 6564 | 'VT323' => 'Google Fonts', |
| 6565 | 'Vampiro One' => 'Google Fonts', |
| 6566 | 'Varela' => 'Google Fonts', |
| 6567 | 'Varela Round' => 'Google Fonts', |
| 6568 | 'Vast Shadow' => 'Google Fonts', |
| 6569 | 'Vesper Libre' => 'Google Fonts', |
| 6570 | 'Vibur' => 'Google Fonts', |
| 6571 | 'Vidaloka' => 'Google Fonts', |
| 6572 | 'Viga' => 'Google Fonts', |
| 6573 | 'Voces' => 'Google Fonts', |
| 6574 | 'Volkhov' => 'Google Fonts', |
| 6575 | 'Vollkorn' => 'Google Fonts', |
| 6576 | 'Vollkorn SC' => 'Google Fonts', |
| 6577 | 'Voltaire' => 'Google Fonts', |
| 6578 | 'Waiting for the Sunrise' => 'Google Fonts', |
| 6579 | 'Wallpoet' => 'Google Fonts', |
| 6580 | 'Walter Turncoat' => 'Google Fonts', |
| 6581 | 'Warnes' => 'Google Fonts', |
| 6582 | 'Wellfleet' => 'Google Fonts', |
| 6583 | 'Wendy One' => 'Google Fonts', |
| 6584 | 'Wire One' => 'Google Fonts', |
| 6585 | 'Work Sans' => 'Google Fonts', |
| 6586 | 'Yanone Kaffeesatz' => 'Google Fonts', |
| 6587 | 'Yantramanav' => 'Google Fonts', |
| 6588 | 'Yatra One' => 'Google Fonts', |
| 6589 | 'Yellowtail' => 'Google Fonts', |
| 6590 | 'Yeon Sung' => 'Google Fonts', |
| 6591 | 'Yeseva One' => 'Google Fonts', |
| 6592 | 'Yesteryear' => 'Google Fonts', |
| 6593 | 'Yrsa' => 'Google Fonts', |
| 6594 | 'Zeyada' => 'Google Fonts', |
| 6595 | 'Zilla Slab' => 'Google Fonts', |
| 6596 | 'Zilla Slab Highlight' => 'Google Fonts', |
| 6597 | ]; |
| 6598 | |
| 6599 | }//end get_font_list() |
| 6600 | |
| 6601 | |
| 6602 | /** |
| 6603 | * Set Default folder order if not exists |
| 6604 | * |
| 6605 | * @since 1.0.0 |
| 6606 | * @access public |
| 6607 | * @return $fonts |
| 6608 | */ |
| 6609 | public function set_default_values_if_not_exists() |
| 6610 | { |
| 6611 | if (is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) { |
| 6612 | $options = get_option('folders_settings'); |
| 6613 | $options = empty($options) || !is_array($options) ? [] : $options; |
| 6614 | foreach ($options as $option) { |
| 6615 | $post_type = self::get_custom_post_type($option); |
| 6616 | $terms = get_terms( |
| 6617 | $post_type, |
| 6618 | [ |
| 6619 | 'hide_empty' => false, |
| 6620 | 'meta_query' => [ |
| 6621 | [ |
| 6622 | 'key' => 'wcp_custom_order', |
| 6623 | 'compare' => 'NOT EXISTS', |
| 6624 | ], |
| 6625 | ], |
| 6626 | ] |
| 6627 | ); |
| 6628 | if (!empty($terms)) { |
| 6629 | foreach ($terms as $term) { |
| 6630 | $order = get_term_meta($term->term_id, "wcp_custom_order", true); |
| 6631 | if (empty($order) || $order == null) { |
| 6632 | update_term_meta($term->term_id, "wcp_custom_order", "1"); |
| 6633 | } |
| 6634 | } |
| 6635 | } |
| 6636 | }//end foreach |
| 6637 | }//end if |
| 6638 | |
| 6639 | }//end set_default_values_if_not_exists() |
| 6640 | |
| 6641 | |
| 6642 | // Free and Pro major changes |
| 6643 | |
| 6644 | |
| 6645 | /** |
| 6646 | * Hide Folder intro Popup |
| 6647 | * |
| 6648 | * @since 1.0.0 |
| 6649 | * @access public |
| 6650 | */ |
| 6651 | public function premio_hide_child_popup() |
| 6652 | { |
| 6653 | $post_type = $this->getRequestVar('post_type'); |
| 6654 | $nonce = $this->getRequestVar('nonce'); |
| 6655 | if (!empty($post_type) && wp_verify_nonce($nonce, 'wcp_folder_nonce_'.$post_type)) { |
| 6656 | $status = $this->getRequestVar('status'); |
| 6657 | $status = ($status == 1) ? 1 : 0; |
| 6658 | if ($status) { |
| 6659 | add_option("premio_hide_child_popup", 1); |
| 6660 | } else { |
| 6661 | delete_option("premio_hide_child_popup"); |
| 6662 | } |
| 6663 | } |
| 6664 | |
| 6665 | echo esc_attr("1"); |
| 6666 | die; |
| 6667 | |
| 6668 | }//end premio_hide_child_popup() |
| 6669 | |
| 6670 | |
| 6671 | /** |
| 6672 | * Hide Folder intro Popup |
| 6673 | * |
| 6674 | * @since 1.0.0 |
| 6675 | * @access public |
| 6676 | */ |
| 6677 | public function folder_update_popup_status() |
| 6678 | { |
| 6679 | $nonce = $this->getRequestVar('nonce'); |
| 6680 | if (!empty($nonce) && wp_verify_nonce($nonce, 'folder_update_popup_status')) { |
| 6681 | update_option("folder_intro_box", "hide"); |
| 6682 | } |
| 6683 | |
| 6684 | echo esc_attr("1"); |
| 6685 | die; |
| 6686 | |
| 6687 | }//end folder_update_popup_status() |
| 6688 | |
| 6689 | |
| 6690 | /** |
| 6691 | * Hide Folder import Popup |
| 6692 | * |
| 6693 | * @since 1.0.0 |
| 6694 | * @access public |
| 6695 | */ |
| 6696 | public function update_folders_import_status() |
| 6697 | { |
| 6698 | $nonce = $this->getRequestVar('nonce'); |
| 6699 | if (!empty($nonce) && wp_verify_nonce($nonce, 'folders_import_3rd_party_data')) { |
| 6700 | update_option("folder_redirect_status", "3"); |
| 6701 | } |
| 6702 | |
| 6703 | echo esc_attr("1"); |
| 6704 | die; |
| 6705 | |
| 6706 | }//end update_folders_import_status() |
| 6707 | |
| 6708 | |
| 6709 | /** |
| 6710 | * Check folders has valid key |
| 6711 | * |
| 6712 | * @since 1.0.0 |
| 6713 | * @access public |
| 6714 | */ |
| 6715 | public function check_has_valid_key() |
| 6716 | { |
| 6717 | // Free/Pro: checking for key, for Free return 0, for Pro check for Key |
| 6718 | return 0; |
| 6719 | |
| 6720 | }//end check_has_valid_key() |
| 6721 | |
| 6722 | |
| 6723 | /** |
| 6724 | * Get license information |
| 6725 | * |
| 6726 | * @since 1.0.0 |
| 6727 | * @access public |
| 6728 | */ |
| 6729 | public function get_license_key_information($licenseKey) |
| 6730 | { |
| 6731 | return []; |
| 6732 | |
| 6733 | }//end get_license_key_information() |
| 6734 | |
| 6735 | |
| 6736 | /** |
| 6737 | * Get license key data |
| 6738 | * |
| 6739 | * @since 1.0.0 |
| 6740 | * @access public |
| 6741 | */ |
| 6742 | public function get_license_key_data($licenseKey='') |
| 6743 | { |
| 6744 | return []; |
| 6745 | |
| 6746 | }//end get_license_key_data() |
| 6747 | |
| 6748 | |
| 6749 | /** |
| 6750 | * Check for license key data |
| 6751 | * |
| 6752 | * @since 1.0.0 |
| 6753 | * @access public |
| 6754 | */ |
| 6755 | public function check_for_license_key() |
| 6756 | { |
| 6757 | return false; |
| 6758 | |
| 6759 | }//end check_for_license_key() |
| 6760 | |
| 6761 | |
| 6762 | }//end class |
| 6763 | |
| 6764 | |
| 6765 | if(!function_exists("folders_sanitize_text")) { |
| 6766 | function folders_sanitize_text($key ,$type = "post") { |
| 6767 | if($type == "post") { |
| 6768 | $string = isset($_POST[$key])?sanitize_text_field($_POST[$key]):""; |
| 6769 | } else { |
| 6770 | $string = isset($_GET[$key])?sanitize_text_field($_GET[$key]):""; |
| 6771 | } |
| 6772 | $string = stripslashes($string); |
| 6773 | $str = preg_replace('/\x00|<[^>]*>?/', '', $string); |
| 6774 | return str_replace(["'", '"'], [''', '"'], $str); |
| 6775 | } |
| 6776 | } |
| 6777 |