'Version')); define('ABJ404_VERSION', $plugin_data['Version']); // Load the Uninstaller class require_once __DIR__ . '/includes/uninstall/Uninstaller.php'; require_once __DIR__ . '/includes/settings/StorageOptionContracts.php'; // Get saved preferences from the uninstall modal // Use site option for network-activated plugins, regular option for single-site $option_name = 'abj404_uninstall_preferences'; $preferences = false; if (is_multisite()) { // Check if the plugin is network-activated if (!function_exists('is_plugin_active_for_network')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $plugin_file = '404-solution/404-solution.php'; $is_network_active = is_plugin_active_for_network($plugin_file); if ($is_network_active) { // Network-activated: Get from site options $preferences = get_site_option($option_name); } else { // Site-specific activation: Get from regular options $preferences = get_option($option_name); } } else { // Single-site: Get from regular options $preferences = get_option($option_name); } // If no preferences were saved, use safe defaults // This happens if user deleted plugin without using the modal if (false === $preferences || !is_array($preferences)) { $preferences = array( 'delete_redirects' => false, // Default: KEEP redirects (user might reinstall) 'delete_logs' => false, // Default: KEEP logs (historical data) 'delete_cache' => true, // Default: DELETE cache (can be rebuilt) 'send_feedback' => false, // Default: Don't send feedback 'uninstall_reason' => '', 'feedback_email' => '', 'feedback_details' => '' ); } $preferences = ABJ_404_Solution_StorageOptionContracts::normalizeForRead($option_name, $preferences); // Delete the preferences (cleanup) if (is_multisite() && $is_network_active) { delete_site_option($option_name); } else { delete_option($option_name); } // Handle both single-site and multisite installations if (is_multisite()) { // Check if the plugin is network-activated // Only run network-wide uninstall if it was activated network-wide if (!function_exists('is_plugin_active_for_network')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } // Determine the plugin file path relative to plugins directory $plugin_file = '404-solution/404-solution.php'; $is_network_active = is_plugin_active_for_network($plugin_file); if ($is_network_active) { // Network-activated: Uninstall from all sites in the network ABJ_404_Solution_Uninstaller::multisite_uninstall($preferences); } else { // Single-site activation: Only uninstall from current site ABJ_404_Solution_Uninstaller::uninstall($preferences); } } else { // Single site installation: Standard uninstall ABJ_404_Solution_Uninstaller::uninstall($preferences); } // All done! WordPress will now delete the plugin files.