isset($_POST['auto_whitelist_same_root']) ? 1 : 0, 'search_engines' => isset($_POST['auto_whitelist_search_engines']) ? 1 : 0 ); $old_options_json = json_encode($old_options); $new_options_json = json_encode($options); $data_changed = ($old_options_json !== $new_options_json); if ($data_changed) { $result = update_option('wpnav_links_options', $options); if ($result !== false) { $success_message = __('Whitelist settings saved successfully!', 'wpnav-links'); } else { $error_message = __('Failed to save whitelist settings. Database error.', 'wpnav-links'); } } else { $success_message = __('Whitelist settings saved successfully!', 'wpnav-links'); } $current_tab = 'whitelist'; } } if (isset($_POST['wpnav_redirect_nonce']) && wp_verify_nonce($_POST['wpnav_redirect_nonce'], 'wpnav_redirect_page_nonce')) { if (!current_user_can('manage_options')) { $error_message = __('You do not have sufficient permissions to access this page.', 'wpnav-links'); } else { $old_options = get_option('wpnav_links_options', array()); $options = $old_options; $options['template'] = isset($_POST['template']) ? sanitize_text_field($_POST['template']) : 'default'; $options['color_scheme'] = isset($_POST['color_scheme']) ? sanitize_text_field($_POST['color_scheme']) : 'blue'; $options['page_title'] = isset($_POST['page_title']) ? sanitize_text_field($_POST['page_title']) : 'External Link Warning'; $options['page_subtitle'] = isset($_POST['page_subtitle']) ? sanitize_text_field($_POST['page_subtitle']) : ''; $options['url_label'] = isset($_POST['url_label']) ? sanitize_text_field($_POST['url_label']) : 'You are about to visit:'; $options['warning_text'] = isset($_POST['warning_text']) ? sanitize_textarea_field($_POST['warning_text']) : ''; $options['show_warning_message'] = isset($_POST['show_warning_message']) ? 1 : 0; $options['show_logo'] = isset($_POST['show_logo']) ? 1 : 0; $options['show_url_full'] = isset($_POST['show_url_full']) ? 1 : 0; $options['show_security_info'] = isset($_POST['show_security_info']) ? 1 : 0; $options['show_security_tips'] = isset($_POST['show_security_tips']) ? 1 : 0; $options['show_back_button'] = isset($_POST['show_back_button']) ? 1 : 0; $options['custom_css'] = isset($_POST['custom_css']) ? wp_strip_all_tags($_POST['custom_css']) : ''; $options['button_text_continue'] = isset($_POST['button_text_continue']) ? sanitize_text_field($_POST['button_text_continue']) : 'Continue'; $options['button_text_back'] = isset($_POST['button_text_back']) ? sanitize_text_field($_POST['button_text_back']) : 'Back'; $options['button_style'] = isset($_POST['button_style']) ? sanitize_text_field($_POST['button_style']) : 'rounded'; $options['countdown_text'] = isset($_POST['countdown_text']) ? sanitize_text_field($_POST['countdown_text']) : 'Auto redirect in {seconds} seconds'; $options['show_progress_bar'] = isset($_POST['show_progress_bar']) ? 1 : 0; $old_options_json = json_encode($old_options); $new_options_json = json_encode($options); $data_changed = ($old_options_json !== $new_options_json); if ($data_changed) { $result = update_option('wpnav_links_options', $options); if ($result !== false) { $success_message = __('Redirect page settings saved successfully!', 'wpnav-links'); } else { $error_message = __('Failed to save redirect page settings. Database error.', 'wpnav-links'); } } else { $success_message = __('Redirect page settings saved successfully!', 'wpnav-links'); } $current_tab = 'redirect_page'; } } if (isset($_POST['wpnav_import_nonce']) && wp_verify_nonce($_POST['wpnav_import_nonce'], 'wpnav_import_csv')) { if (!current_user_can('manage_options')) { $error_message = __('You do not have sufficient permissions to access this page.', 'wpnav-links'); } elseif (!$wp_china_yes_active) { $error_message = __('Import functionality requires 文派叶子 🍃(WPCY.COM)to be active.', 'wpnav-links'); } else { if (!empty($_FILES['whitelist_csv']['tmp_name'])) { $csv_file = $_FILES['whitelist_csv']['tmp_name']; $domains = array(); if (($handle = fopen($csv_file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if (!empty($data[0])) { $domains[] = sanitize_text_field($data[0]); } } fclose($handle); } if (!empty($domains)) { $options = get_option('wpnav_links_options', array()); $existing_domains = explode("\n", isset($options['whitelist_domains']) ? $options['whitelist_domains'] : ''); $existing_domains = array_map('trim', $existing_domains); $combined_domains = array_merge($existing_domains, $domains); $combined_domains = array_filter($combined_domains); $combined_domains = array_unique($combined_domains); $options['whitelist_domains'] = implode("\n", $combined_domains); $result = update_option('wpnav_links_options', $options); if ($result !== false) { $imported_count = count($domains); $success_message = sprintf(__('Successfully imported %d domains.', 'wpnav-links'), $imported_count); } else { $error_message = __('Failed to import CSV data. Database error.', 'wpnav-links'); } } else { $error_message = __('No valid domains found in the CSV file.', 'wpnav-links'); } } else { $error_message = __('Please select a CSV file to upload.', 'wpnav-links'); } $current_tab = 'import_export'; } } if (isset($_GET['message'])) { $message_type = sanitize_text_field($_GET['message']); if ($message_type === 'saved') { $success_message = __('Settings saved successfully!', 'wpnav-links'); } elseif ($message_type === 'imported') { $count = isset($_GET['count']) ? intval($_GET['count']) : 0; $success_message = sprintf(__('Successfully imported %d domains.', 'wpnav-links'), $count); } } $options = get_option('wpnav_links_options', array()); $current_time = current_time('timestamp'); $end_date = isset($_GET['end_date']) ? sanitize_text_field($_GET['end_date']) : date('Y-m-d', $current_time); $start_date = isset($_GET['start_date']) ? sanitize_text_field($_GET['start_date']) : date('Y-m-d', strtotime('-30 days', $current_time)); $limit = 20; $current_page = isset($_GET['paged']) ? max(1, intval($_GET['paged'])) : 1; $offset = ($current_page - 1) * $limit; $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'click_time'; $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; $stats = $plugin->get_stats(array( 'start_date' => $start_date, 'end_date' => $end_date, 'limit' => $limit, 'offset' => $offset, 'order_by' => $orderby, 'order' => $order )); $total_items = $plugin->get_total_count($start_date, $end_date); $total_pages = ceil($total_items / $limit); $top_urls = $plugin->get_top_urls(10); $custom_template_exists = file_exists(get_stylesheet_directory() . '/wpnav-redirect-template.php') || file_exists(get_template_directory() . '/wpnav-redirect-template.php'); ?>

prefix . WPNAV_LINKS_TABLE; ?>