-
Notifications
You must be signed in to change notification settings - Fork 3
/
uninstall.php
65 lines (52 loc) · 1.35 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
<?php
/**
* Fired when the plugin is uninstalled.
*
* @author WP-Translations Team
* @link https:wp-translations.pro
* @since 1.0.0
*
* @package WPT_Custom_Mo_File
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Delete WPT_CUSTOMOFILE options.
if ( is_multisite() ) {
global $wpdb;
foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ) as $blog_id ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.WP.GlobalVariablesOverride.Prohibited
switch_to_blog( $blog_id );
delete_option( 'wpt_customofile_options' );
restore_current_blog();
}
} else {
delete_option( 'wpt_customofile_options' );
}
/**
* Remove all mo files.
*
* @since 1.0.0
*
* @param string $dir Filename.
*
* @return void
*/
function wpt_customofile_rrmdir( $dir ) {
if ( ! is_dir( $dir ) ) {
unlink( $dir );
return;
}
$globs = glob( $dir . '/*', GLOB_NOSORT );
if ( $globs ) {
foreach ( $globs as $file ) {
is_dir( $file ) ? wpt_customofile_rrmdir( $file ) : unlink( $file );
}
// Unset unused variable.
unset( $globs );
}
rmdir( $dir );
}
$wpt_customofile_upload_dir = wp_upload_dir();
$wpt_customofile_upload_dir = $wpt_customofile_upload_dir['basedir'] . '/wpt-custom-mo-file';
wpt_customofile_rrmdir( $wpt_customofile_upload_dir );