-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisable-empty-trash.php
39 lines (34 loc) · 1.06 KB
/
disable-empty-trash.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
<?php
/*
Plugin Name: Disable Empty Trash
Plugin URI: https://www.littlebizzy.com/plugins/disable-empty-trash
Description: Stops WordPress emptying trash
Version: 2.0.3
Requires PHP: 7.0
Tested up to: 6.7
Author: LittleBizzy
Author URI: https://www.littlebizzy.com
License: GPL3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Update URI: false
GitHub Plugin URI: littlebizzy/disable-empty-trash
Primary Branch: master
Text Domain: disable-empty-trash
*/
// prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// override wordpress.org with git updater
add_filter( 'gu_override_dot_org', function( $overrides ) {
$overrides[] = 'disable-empty-trash/disable-empty-trash.php';
return $overrides;
}, 999 );
// disable automatic trash emptying
function disable_empty_trash() {
remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
}
// hook to init with high priority
add_action( 'init', 'disable_empty_trash', -999 );
// Ref: ChatGPT
// Ref: using define( 'EMPTY_TRASH_DAYS', 36500 ); in wp-config.php alongside this plugin is recommended