Skip to content

Commit

Permalink
Add uninstall routine to cleanup the database
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Apr 4, 2024
1 parent f73f33b commit d4988f2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions uninstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Uninstall the plugin.
*
* Deletes the custom database tables, and the plugin options.
*
* @package ProgressPlanner
*/

// If uninstall not called from WordPress, then exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}

require_once __DIR__ . '/includes/class-settings.php';
require_once __DIR__ . '/includes/class-query.php';

// Delete the plugin options.
delete_option( \ProgressPlanner\Settings::OPTION_NAME );

// Delete the custom database tables.
global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query(
$wpdb->prepare(
// phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnsupportedIdentifierPlaceholder, WordPress.DB.DirectDatabaseQuery.SchemaChange
'DROP TABLE IF EXISTS %i',
$wpdb->prefix . \ProgressPlanner\Query::TABLE_NAME
)
);

0 comments on commit d4988f2

Please sign in to comment.