-
Notifications
You must be signed in to change notification settings - Fork 53
/
uninstall.php
56 lines (47 loc) · 1.49 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
namespace Mollie\WooCommerce;
use Inpsyde\Modularity\Package;
use Inpsyde\Modularity\Properties\PluginProperties;
use Mollie\WooCommerce\Uninstall\CleanDb;
use Mollie\WooCommerce\Uninstall\UninstallModule;
use Throwable;
if ( !defined('WP_UNINSTALL_PLUGIN' ) ) {
die('Direct access not allowed.');
}
(static function (): void {
if (
file_exists(__DIR__ . '/vendor/autoload.php')
) {
include_once __DIR__ . '/vendor/autoload.php';
}
try {
$properties = PluginProperties::new(__FILE__);
$bootstrap = Package::new($properties);
$bootstrap->boot(
new UninstallModule()
);
$shouldClean = get_option('mollie-payments-for-woocommerce_removeOptionsAndTransients') === 'yes';
if($shouldClean){
$cleaner = $bootstrap->container()->get(CleanDb::class);
$cleaner->cleanAll();
}
} catch (Throwable $throwable) {
$message = sprintf(
'<strong>Error:</strong> %s <br><pre>%s</pre>',
$throwable->getMessage(),
$throwable->getTraceAsString()
);
add_action(
'all_admin_notices',
static function () use ($message) {
$class = 'notice notice-error';
printf(
'<div class="%1$s"><p>%2$s</p></div>',
esc_attr($class),
wp_kses_post($message)
);
}
);
}
})();