prefix . $table ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Intentional schema removal during plugin uninstallation, table name is escaped $wpdb->query( "DROP TABLE IF EXISTS {$table_name}" ); } error_log( 'AdminEase: Database tables dropped during uninstall' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log } /** * Clear all AdminEase scheduled cron events. * * Hook names must match those scheduled in includes/Features/NetworkViewer.php, * EmailLog.php and CronViewerLog.php, and cleared in the adminease.php * deactivation hook. */ function adminease_clear_cron_events(): void { $hooks = [ 'adminease_cleanup_network_viewer_logs', 'adminease_cleanup_email_logs', 'adminease_cleanup_cron_viewer_logs', ]; foreach ( $hooks as $hook ) { wp_clear_scheduled_hook( $hook ); } error_log( 'AdminEase: Scheduled cron events cleared during uninstall' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log } /** * Optional: Delete plugin options. * * By design, plugin settings are PRESERVED across uninstall so that a user who * deletes-then-reinstalls AdminEase does not lose configuration. This matches * the behavior documented in DOCUMENTATION.md ("Deactivation Behavior" / * "Uninstallation"). Do NOT enable the call to this function below without * also updating the documentation. */ function adminease_delete_plugin_options() { // Delete main plugin options delete_option( 'adminease_settings' ); delete_option( 'adminease_activation_status' ); delete_option( 'adminease_activation_errors' ); delete_option( 'adminease_deactivation_status' ); delete_option( 'adminease_deactivation_errors' ); error_log( 'AdminEase: Plugin options deleted during uninstall' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log } // Execute cleanup operations adminease_drop_tables(); adminease_clear_cron_events(); // Optionally delete plugin options (uncomment the line below to enable) // adminease_delete_plugin_options(); error_log( 'AdminEase: Uninstall completed successfully' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log