-
Notifications
You must be signed in to change notification settings - Fork 12
/
uninstall.php
40 lines (30 loc) · 936 Bytes
/
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
<?php
/**
* Plugin uninstall handler.
*/
namespace Required\Traduttore;
\defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
/* @var \WP_Filesystem_Base $wp_filesystem */
global $wp_filesystem;
if ( ! $wp_filesystem ) {
require_once ABSPATH . '/wp-admin/includes/admin.php';
\WP_Filesystem();
}
if ( $wp_filesystem ) {
array_map(
function ( $file_or_folder ) use ( $wp_filesystem ): void {
$wp_filesystem->delete( $file_or_folder, true, is_dir( $file_or_folder ) ? 'd' : 'f' );
},
glob( get_temp_dir() . 'traduttore-*' )
);
$wp_filesystem->rmdir( ZipProvider::get_cache_dir(), true );
}
/* @var \wpdb $wpdb */
global $wpdb;
$traduttore_meta_key_prefix = '_traduttore_';
$traduttore_query = $wpdb->prepare(
"DELETE FROM `$wpdb->gp_meta` WHERE `meta_key` LIKE %s ",
$wpdb->esc_like( $traduttore_meta_key_prefix ) . '%'
);
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$wpdb->query( $traduttore_query );