-
Notifications
You must be signed in to change notification settings - Fork 3
/
wp-core-update-cleaner.php
111 lines (96 loc) · 2.87 KB
/
wp-core-update-cleaner.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
104
105
106
107
108
109
110
111
<?php
/**
* Plugin Name: WP Core Update Cleaner
* Description: This plugin automatically removes some files in the root folder, like wp-config-sample.php, readme and license files, when WordPress is manually or automatically updated.
* Version: 1.2.0
* Author: Upperdog
* Author URI: https://upperdog.com
* Author Email: [email protected]
* License: GPL2
*/
/* Copyright 2014 Upperdog (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
}
class WPCoreUpdateCleaner {
/**
* Sets up hooks, actions and filters that the plugin responds to.
*
* @since 1.0
*/
function __construct() {
register_activation_hook( __FILE__, array( $this, 'plugin_activation' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( '_core_updated_successfully', array( $this, 'core_update_cleaner' ) );
}
/**
* Plugin activation
*
* @since 1.2.0
*/
function plugin_activation() {
$this->core_update_cleaner();
}
/**
* Sets up plugin translations.
*
* @since 1.0
*/
function admin_init() {
load_plugin_textdomain( 'wp-core-update-cleaner', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Core update cleaner
*
* @since 1.0
* @since 1.1.0 Renamed function, refactored and enabled update cleaner for automatic core updates.
*/
function core_update_cleaner() {
global $action;
// Show update feedback for manual updates
if ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
$show_message = true;
} else {
$show_message = false;
}
// Define files to remove
$files_to_remove = array(
'license.txt',
'licens.html',
'licenza.html',
'licencia.txt',
'licenc.txt',
'licencia-sk_SK.txt',
'licens-sv_SE.txt',
'liesmich.html',
'LEGGIMI.txt',
'lisenssi.html',
'olvasdel.html',
'readme.html',
'readme-ja.html',
'wp-config-sample.php',
'wp-admin/install.php'
);
foreach ( $files_to_remove as $file ) {
if ( file_exists( ABSPATH . $file ) ) {
if ( unlink( ABSPATH . $file ) ) {
if ( $show_message ) {
show_message( __( 'Removing', 'wp-core-update-cleaner' ) . ' ' . $file . '...' );
}
}
}
}
}
}
$wp_core_update_cleaner = new WPCoreUpdateCleaner();