From be97d18c46d07bfb040234a17aebe191f43f4773 Mon Sep 17 00:00:00 2001 From: Michelle Blanchette Date: Tue, 5 Nov 2024 22:56:50 -0500 Subject: [PATCH] final plugin with uninstallation hook --- .../07-Custom-Database-Tables/wpl-form-submissions.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugin-developer-learning-pathway/07-Custom-Database-Tables/wpl-form-submissions.php b/plugin-developer-learning-pathway/07-Custom-Database-Tables/wpl-form-submissions.php index add09e7..125d866 100644 --- a/plugin-developer-learning-pathway/07-Custom-Database-Tables/wpl-form-submissions.php +++ b/plugin-developer-learning-pathway/07-Custom-Database-Tables/wpl-form-submissions.php @@ -42,3 +42,10 @@ function wp_learn_custom_table_update_db_check() { wp_learn_custom_table_create_submissions_table(); } } + +register_uninstall_hook( __FILE__, 'wp_learn_custom_table_delete_submissions_table' ); +function wp_learn_custom_table_delete_submissions_table() { + global $wpdb; + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}wpl_submissions" ); + delete_option( 'wp_learn_custom_table_db_version' ); +}