__('Element', 'advanced-database-cleaner'), //singular name of the listed records 'plural' => __('Elements', 'advanced-database-cleaner'), //plural name of the listed records 'ajax' => false //does this table support ajax? )); $this->aDBc_prepare_elements_to_clean(); $this->aDBc_print_page_content(); } /** Prepare elements to display */ function aDBc_prepare_elements_to_clean(){ // Test if user wants to delete a scheduled task if(isset($_POST['aDBc_delete_schedule'])){ //Quick nonce security check! if(!check_admin_referer('delete_cleanup_schedule_nonce', 'delete_cleanup_schedule_nonce')) return; //get out if we didn't click the delete link // We delete the schedule $aDBc_sanitized_schedule_name = sanitize_html_class($_POST['aDBc_delete_schedule']); wp_clear_scheduled_hook('aDBc_clean_scheduler', array($aDBc_sanitized_schedule_name)); // We delete the item from database $aDBc_schedules = get_option('aDBc_clean_schedule'); unset($aDBc_schedules[$aDBc_sanitized_schedule_name]); update_option('aDBc_clean_schedule', $aDBc_schedules, "no"); $this->aDBc_message = __('The clean-up schedule deleted successfully!', 'advanced-database-cleaner'); } // Test if user wants to edit keep_last column for an item if(isset($_POST['aDBc_keep_input'])){ // Security check - verify nonce if(!check_admin_referer('aDBc_keep_last_nonce', 'aDBc_keep_last_nonce')) return; //get out if nonce verification fails $sanitized_keep_input = sanitize_html_class($_POST['aDBc_keep_input']); $sanitized_item_keep_to_edit = sanitize_html_class($_POST['aDBc_item_keep_to_edit']); $settings = get_option('aDBc_settings'); if(empty($settings['keep_last'])){ $keep_value = array($sanitized_item_keep_to_edit => intval($sanitized_keep_input)); }else{ $keep_value = $settings['keep_last']; $keep_value[$sanitized_item_keep_to_edit] = intval($sanitized_keep_input); } $settings['keep_last'] = $keep_value; update_option('aDBc_settings', $settings, "no"); // Test if the items belongs to a scheduled task. If so, show msg differently $aDBc_schedules = get_option('aDBc_clean_schedule'); $aDBc_schedules = is_array($aDBc_schedules) ? $aDBc_schedules : array(); $msg_keep_last = __("The 'keep last' value saved successfully!", "advanced-database-cleaner"); foreach($aDBc_schedules as $hook_name => $hook_params){ $lits_of_elements = $hook_params['elements_to_clean']; if(in_array($sanitized_item_keep_to_edit, $lits_of_elements)){ $msg_keep_last = __("The 'keep last' value saved successfully!", "advanced-database-cleaner") . " " . __("Please keep in mind that this will change the value of 'keep last' of your corresponding scheduled tasks as well!", "advanced-database-cleaner") . ""; break; } } $this->aDBc_message = $msg_keep_last; } // Process bulk action if any before preparing elements to clean $this->process_bulk_action(); // Get all unused elements $aDBc_unused_elements = aDBc_count_all_elements_to_clean(); $aDBc_new_URI = $_SERVER['REQUEST_URI']; // Get settings from DB $settings = get_option('aDBc_settings'); $aDBc_schedules = get_option('aDBc_clean_schedule'); $aDBc_schedules = is_array($aDBc_schedules) ? $aDBc_schedules : array(); foreach($aDBc_unused_elements as $element_type => $element_info){ // Count total unused elements $this->aDBc_total_elements_to_clean += $element_info['count']; // If the item is scheduled, show green image, otherwise show grey one. Select also the text to show next green image $scheduled_img_name = "grey_clock.svg"; $item_scheduled_in = ""; foreach($aDBc_schedules as $hook_name => $hook_params){ $lits_of_elements = $hook_params['elements_to_clean']; if(in_array ($element_type, $lits_of_elements)){ $scheduled_img_name = "green_clock.svg"; $item_scheduled_in .= "