-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
37 lines (30 loc) · 1.06 KB
/
uninstall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
* EAccounting Uninstall
*
* Uninstalling EAccounting deletes user roles, tables, and options.
*
* @package EAccounting\Uninstaller
* @version 1.1.0
*/
defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
// clear events.
wp_clear_scheduled_hook( 'eaccounting_twicedaily_scheduled_events' );
wp_clear_scheduled_hook( 'eaccounting_daily_scheduled_events' );
wp_clear_scheduled_hook( 'eaccounting_weekly_scheduled_events' );
/*
* Only remove ALL product and page data if EACCOUNTING_REMOVE_ALL_DATA constant is set to true in user's
* wp-config.php. This is to prevent data loss when deleting the plugin from the backend
* and to ensure only the site owner can perform this action.
*/
if ( defined( 'EACCOUNTING_REMOVE_ALL_DATA' ) && true === EACCOUNTING_REMOVE_ALL_DATA ) {
global $wpdb;
// Roles.
\EAccounting\Install::remove_roles();
// Tables.
\EAccounting\Install::drop_tables();
// Delete options.
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'eaccounting\_%';" );
// Clear any cached data that has been removed.
wp_cache_flush();
}