forked from importwp/importwp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.php
52 lines (40 loc) · 1.34 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
<?php
// if uninstall.php is not called by WordPress, die
use ImportWP\Common\Importer\ImporterManager;
use ImportWP\Common\Migration\Migrations;
use ImportWP\Container;
if (!defined('WP_UNINSTALL_PLUGIN')) {
die;
}
do_action('iwp/uninstall_plugin');
// Escape if cleanup has not been enabled.
$uninstall_enabled = get_option('iwp_settings');
if (!isset($uninstall_enabled['cleanup']) || true !== $uninstall_enabled['cleanup']) {
return;
}
$iwp_base_path = dirname(__FILE__);
if (file_exists($iwp_base_path . '/importwp-pro.php')) {
require_once $iwp_base_path . '/importwp-pro.php';
} else {
require_once $iwp_base_path . '/jc-importer.php';
}
// 1. Delete all importers, Delete all importer files
/**
* @var ImporterManager $importer_manager
*/
$importer_manager = Container::getInstance()->get('importer_manager');
$importers = $importer_manager->get_importers();
foreach ($importers as $importer) {
$files = $importer->getFiles();
foreach ($files as $file) {
@unlink($file);
}
$importer->delete();
}
// 2. Delete /wp-content/importwp folder
require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
$fileSystemDirect = new \WP_Filesystem_Direct(false);
$fileSystemDirect->rmdir(WP_CONTENT_DIR . '/uploads/importwp', true);
// 3. Uninstall DB
$migrations = new Migrations();
$migrations->uninstall();