|
3 | 3 | Plugin Name: Disable Empty Trash |
4 | 4 | Plugin URI: https://www.littlebizzy.com/plugins/disable-empty-trash |
5 | 5 | Description: Stops WordPress emptying trash |
6 | | -Version: 1.1.0 |
| 6 | +Version: 2.0.0 |
7 | 7 | Author: LittleBizzy |
8 | 8 | Author URI: https://www.littlebizzy.com |
9 | 9 | License: GPL3 |
|
13 | 13 | Prefix: DETTRS |
14 | 14 | */ |
15 | 15 |
|
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 | +}); |
27 | 21 |
|
28 | 22 | /** |
29 | | - * Define main plugin class |
| 23 | + * Disable automatic trash emptying. |
30 | 24 | */ |
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'); |
74 | 28 | } |
75 | 29 |
|
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); |
84 | 32 |
|
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