-
Notifications
You must be signed in to change notification settings - Fork 39
/
uninstall.php
48 lines (30 loc) · 1.21 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
<?php
if ( ! defined( 'ABSPATH' ) || ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit; // Exit if accessed directly}
}
global $wpdb;
WP_Filesystem();
global $wp_filesystem;
$cron = get_option( 'cron' );
foreach ( $cron as $job ) {
if ( is_array( $job ) ) {
$keys = array_keys( $job );
foreach ( $keys as $key ) {
if ( 0 === strpos( $key, 'wppus_' ) ) {
wp_unschedule_hook( $key );
}
}
}
}
$wppus_mu_plugin = trailingslashit( wp_normalize_path( WPMU_PLUGIN_DIR ) ) . 'wppus-endpoint-optimizer.php';
$wppus_dir = trailingslashit( $wp_filesystem->wp_content_dir() . 'wppus' );
$wp_filesystem->delete( $wppus_mu_plugin );
$wp_filesystem->delete( $wppus_mu_plugin . '.backup' );
$wp_filesystem->delete( $wppus_mdir, true );
as_unschedule_all_actions( 'wppus_cleanup' );
$sql = "DELETE FROM $wpdb->options WHERE `option_name` LIKE %s";
$wpdb->query( $wpdb->prepare( $sql, '%wppus_%' ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$sql = "DROP TABLE IF EXISTS {$wpdb->prefix}wppus_licenses;";
$wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$sql = "DROP TABLE IF EXISTS {$wpdb->prefix}wppus_nonce;";
$wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared