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}" ); } delete_option( 'adminease_audit_log_table' ); } /** * Clear all AdminEase scheduled cron events. * * Hook names must match those scheduled in includes/Features/NetworkViewer.php, * EmailLog.php, CronViewerLog.php, HttpRequestLog.php and AuditLog.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', 'adminease_cleanup_http_request_logs', 'adminease_cleanup_audit_log', ]; foreach ( $hooks as $hook ) { wp_clear_scheduled_hook( $hook ); } } /** * 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_option( 'adminease_settings' ); delete_option( 'adminease_activation_status' ); delete_option( 'adminease_activation_errors' ); delete_option( 'adminease_deactivation_status' ); delete_option( 'adminease_deactivation_errors' ); delete_option( 'adminease_backup_dir_notice' ); } // Execute cleanup operations. On a network every site has its own tables and cron events. if ( is_multisite() ) { foreach ( get_sites( [ 'fields' => 'ids', 'number' => 0 ] ) as $adminease_site_id ) { switch_to_blog( $adminease_site_id ); adminease_drop_tables(); adminease_clear_cron_events(); restore_current_blog(); } } else { adminease_drop_tables(); adminease_clear_cron_events(); } // Optionally delete plugin options (uncomment the line below to enable) // adminease_delete_plugin_options();