forked from 10up/ElasticPress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.php
103 lines (90 loc) · 2.33 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* ElasticPress uninstaller
*
* Used when clicking "Delete" from inside of WordPress's plugins page.
*
* @package elasticpress
* @since 1.7
*/
/**
* Class EP_Uninstaller
*/
class EP_Uninstaller {
/**
* Initialize uninstaller
*
* Perform some checks to make sure plugin can/should be uninstalled
*
* @since 1.7
* @return EP_Uninstaller
*/
public function __construct() {
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
$this->exit_uninstaller();
}
// Not uninstalling.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
$this->exit_uninstaller();
}
// Not uninstalling.
if ( ! WP_UNINSTALL_PLUGIN ) {
$this->exit_uninstaller();
}
// Not uninstalling this plugin.
if ( dirname( WP_UNINSTALL_PLUGIN ) !== dirname( plugin_basename( __FILE__ ) ) ) {
$this->exit_uninstaller();
}
// Uninstall ElasticPress.
self::clean_options();
}
/**
* Cleanup options
*
* Deletes ElasticPress options and transients.
*
* @since 1.7
* @return void
*/
protected static function clean_options() {
// Delete options.
delete_site_option( 'ep_host' );
delete_option( 'ep_host' );
delete_site_option( 'ep_index_meta' );
delete_option( 'ep_index_meta' );
delete_site_option( 'ep_feature_settings' );
delete_option( 'ep_feature_settings' );
delete_site_option( 'ep_version' );
delete_option( 'ep_version' );
delete_option( 'ep_intro_shown' );
delete_site_option( 'ep_intro_shown' );
delete_option( 'ep_last_sync' );
delete_site_option( 'ep_last_sync' );
delete_option( 'ep_need_upgrade_sync' );
delete_site_option( 'ep_need_upgrade_sync' );
delete_option( 'ep_feature_requirement_statuses' );
delete_site_option( 'ep_feature_requirement_statuses' );
delete_option( 'ep_feature_auto_activated_sync' );
delete_site_option( 'ep_feature_auto_activated_sync' );
delete_option( 'ep_hide_intro_shown_notice' );
delete_site_option( 'ep_hide_intro_shown_notice' );
delete_option( 'ep_skip_install' );
delete_site_option( 'ep_skip_install' );
delete_option( 'ep_last_cli_index' );
delete_site_option( 'ep_last_cli_index' );
}
/**
* Exit uninstaller
*
* Gracefully exit the uninstaller if we should not be here
*
* @since 1.7
* @return void
*/
protected function exit_uninstaller() {
status_header( 404 );
exit;
}
}
new EP_Uninstaller();