Skip to content

Commit 6a7c238

Browse files
authored
Update disable-empty-trash.php
1 parent 9f47846 commit 6a7c238

File tree

1 file changed

+13
-68
lines changed

1 file changed

+13
-68
lines changed

disable-empty-trash.php

Lines changed: 13 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Disable Empty Trash
44
Plugin URI: https://www.littlebizzy.com/plugins/disable-empty-trash
55
Description: Stops WordPress emptying trash
6-
Version: 1.1.0
6+
Version: 2.0.0
77
Author: LittleBizzy
88
Author URI: https://www.littlebizzy.com
99
License: GPL3
@@ -13,76 +13,21 @@
1313
Prefix: DETTRS
1414
*/
1515

16-
// disable wordpress.org updates
17-
add_filter(
18-
'gu_override_dot_org',
19-
function ( $overrides ) {
20-
return array_merge(
21-
$overrides,
22-
array( 'disable-empty-trash/disable-empty-trash.php' )
23-
);
24-
}
25-
);
26-
16+
// Disable WordPress.org updates for this plugin
17+
add_filter('gu_override_dot_org', function ($overrides) {
18+
$overrides['disable-empty-trash/disable-empty-trash.php'] = true;
19+
return $overrides;
20+
});
2721

2822
/**
29-
* Define main plugin class
23+
* Disable automatic trash emptying.
3024
*/
31-
class LB_Disable_Empty_Trash {
32-
33-
/**
34-
* A reference to an instance of this class.
35-
*
36-
* @since 1.0.0
37-
* @var object
38-
*/
39-
private static $instance = null;
40-
41-
/**
42-
* Initalize plugin actions
43-
*
44-
* @return void
45-
*/
46-
public function init() {
47-
remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
48-
}
49-
50-
/**
51-
* Returns plugin base file
52-
*
53-
* @return string
54-
*/
55-
public static function file() {
56-
return __FILE__;
57-
}
58-
59-
/**
60-
* Returns the instance.
61-
*
62-
* @since 1.0.0
63-
* @return object
64-
*/
65-
public static function get_instance() {
66-
67-
// If the single instance hasn't been set, set it now.
68-
if ( null == self::$instance ) {
69-
self::$instance = new self;
70-
}
71-
72-
return self::$instance;
73-
}
25+
function disable_empty_trash() {
26+
// Remove the scheduled action for emptying trash
27+
remove_action('wp_scheduled_delete', 'wp_scheduled_delete');
7428
}
7529

76-
/**
77-
* Returns instance of LB_Disable_Empty_Trash class
78-
*
79-
* @return object
80-
*/
81-
function lb_disable_empty_trash() {
82-
return LB_Disable_Empty_Trash::get_instance();
83-
}
30+
// Hook the function to 'init' with high priority
31+
add_action('init', 'disable_empty_trash', -999);
8432

85-
/**
86-
* Initalize plugin instance very early on 'init' hook
87-
*/
88-
add_action( 'init', array( lb_disable_empty_trash(), 'init' ), -999 );
33+
// Ref: ChatGPT

0 commit comments

Comments
 (0)