disconnect_site(); if (class_exists('Automattic\\WooCommerce\\Admin\\Notes\\Notes')) { foreach (get_option('agents24x7_notification_note_names', array()) as $name) { \Automattic\WooCommerce\Admin\Notes\Notes::delete_notes_with_name($name); } foreach (get_option('agents24x7_notification_topics', array()) as $kind => $state) { \Automattic\WooCommerce\Admin\Notes\Notes::delete_notes_with_name('agents24x7-waiting-' . $kind); } } // Include state from previous connections, including interrupted note creation. global $wpdb; foreach (array('topics', 'last_note', 'inbox_lock') as $suffix) { $pattern = $wpdb->esc_like('agents24x7_notification_' . $suffix . '_') . '%'; foreach ($wpdb->get_col($wpdb->prepare( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE %s", $pattern )) as $option) { delete_option($option); } } // Remove credentials, plugin settings, and temporary state on explicit uninstall. foreach (array( 'agents24x7_api_token', 'agents24x7_user_data', 'agents24x7_version', 'agents24x7_support_enabled', 'agents24x7_support_toggle_set', 'agents24x7_support_site_enabled', 'agents24x7_support_agent_id', 'agents24x7_support_site_key', 'agents24x7_password_rotation_lock', 'agents24x7_llms_txt', 'agents24x7_notification_note_names', 'agents24x7_notification_topics', 'agents24x7_notification_last_note', 'agents24x7_notification_inbox_lock', ) as $option) { delete_option($option); } delete_transient('agents24x7_message'); delete_transient('agents24x7_service_status'); // Remove any cached data wp_cache_flush(); // Note: WordPress automatically removes plugin files // This script only handles database cleanup