Remove table data on plugin uninstall (https://github.com/woocommerce/woocommerce-admin/pull/2399)
* Remove table data on plugin deactivate * Fix uninstall classes and move table deletion to uninstall
This commit is contained in:
parent
b83ef86add
commit
81ffa853f3
|
@ -89,13 +89,6 @@ class WC_Admin_Api_Init {
|
||||||
require_once WC_ADMIN_ABSPATH . 'includes/data-stores/class-wc-admin-reports-customers-data-store.php';
|
require_once WC_ADMIN_ABSPATH . 'includes/data-stores/class-wc-admin-reports-customers-data-store.php';
|
||||||
require_once WC_ADMIN_ABSPATH . 'includes/data-stores/class-wc-admin-reports-customers-stats-data-store.php';
|
require_once WC_ADMIN_ABSPATH . 'includes/data-stores/class-wc-admin-reports-customers-stats-data-store.php';
|
||||||
require_once WC_ADMIN_ABSPATH . 'includes/data-stores/class-wc-admin-reports-stock-stats-data-store.php';
|
require_once WC_ADMIN_ABSPATH . 'includes/data-stores/class-wc-admin-reports-stock-stats-data-store.php';
|
||||||
|
|
||||||
// Data triggers.
|
|
||||||
require_once WC_ADMIN_ABSPATH . 'includes/data-stores/class-wc-admin-notes-data-store.php';
|
|
||||||
|
|
||||||
// CRUD classes.
|
|
||||||
require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-note.php';
|
|
||||||
require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes.php';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -273,6 +273,19 @@ class WC_Admin_Install {
|
||||||
WC_Admin_Notes_Historical_Data::add_note();
|
WC_Admin_Notes_Historical_Data::add_note();
|
||||||
WC_Admin_Notes_Welcome_Message::add_welcome_note();
|
WC_Admin_Notes_Welcome_Message::add_welcome_note();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all data from tables.
|
||||||
|
*/
|
||||||
|
public static function delete_table_data() {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$tables = self::get_tables();
|
||||||
|
|
||||||
|
foreach ( $tables as $table ) {
|
||||||
|
$wpdb->query( "TRUNCATE TABLE {$table}" ); // WPCS: unprepared SQL ok.
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WC_Admin_Install::init();
|
WC_Admin_Install::init();
|
||||||
|
|
|
@ -22,6 +22,26 @@ class WC_Admin_Notes {
|
||||||
*/
|
*/
|
||||||
const QUEUE_GROUP = 'wc-admin-notes';
|
const QUEUE_GROUP = 'wc-admin-notes';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queue instance.
|
||||||
|
*
|
||||||
|
* @var WC_Queue_Interface
|
||||||
|
*/
|
||||||
|
protected static $queue = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get queue instance.
|
||||||
|
*
|
||||||
|
* @return WC_Queue_Interface
|
||||||
|
*/
|
||||||
|
public static function queue() {
|
||||||
|
if ( is_null( self::$queue ) ) {
|
||||||
|
self::$queue = WC()->queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$queue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook appropriate actions.
|
* Hook appropriate actions.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
|
|
||||||
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
|
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
|
||||||
|
|
||||||
WC_Admin::instance()->includes();
|
require_once dirname( __FILE__ ) . '/woocommerce-admin.php';
|
||||||
|
|
||||||
|
WC_Admin_Feature_Plugin::instance()->includes();
|
||||||
WC_Admin_Reports_Sync::clear_queued_actions();
|
WC_Admin_Reports_Sync::clear_queued_actions();
|
||||||
WC_Admin_Notes::clear_queued_actions();
|
WC_Admin_Notes::clear_queued_actions();
|
||||||
|
WC_Admin_Install::delete_table_data();
|
||||||
wp_clear_scheduled_hook( 'wc_admin_daily' );
|
wp_clear_scheduled_hook( 'wc_admin_daily' );
|
||||||
|
|
|
@ -61,7 +61,7 @@ class WC_Admin_Feature_Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install DB and create cron events when activated,
|
* Install DB and create cron events when activated.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -125,6 +125,13 @@ class WC_Admin_Feature_Plugin {
|
||||||
require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-events.php';
|
require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-events.php';
|
||||||
require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-api-init.php';
|
require_once WC_ADMIN_ABSPATH . 'includes/class-wc-admin-api-init.php';
|
||||||
|
|
||||||
|
// Data triggers.
|
||||||
|
require_once WC_ADMIN_ABSPATH . 'includes/data-stores/class-wc-admin-notes-data-store.php';
|
||||||
|
|
||||||
|
// CRUD classes.
|
||||||
|
require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-note.php';
|
||||||
|
require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes.php';
|
||||||
|
|
||||||
// Admin note providers.
|
// Admin note providers.
|
||||||
// @todo These should be bundled in the features/ folder, but loading them from there currently has a load order issue.
|
// @todo These should be bundled in the features/ folder, but loading them from there currently has a load order issue.
|
||||||
require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes-new-sales-record.php';
|
require_once WC_ADMIN_ABSPATH . 'includes/notes/class-wc-admin-notes-new-sales-record.php';
|
||||||
|
|
Loading…
Reference in New Issue