Skip to content

Commit 245e20f

Browse files
authored
v7.9.3-a2: Core: uninstall from uninstall.php instead of register_uninstall_hook() (#1078)
1 parent 01ded36 commit 245e20f

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

‎src/core.cls.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,17 @@ public function __construct() {
9393
}
9494

9595
/**
96-
* Register plugin activate/deactivate/uninstall hooks
96+
* Register plugin activate/deactivate hooks
9797
* NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed
9898
*
99+
* Uninstall runs from uninstall.php: register_uninstall_hook() reads the non-autoloaded
100+
* `uninstall_plugins` option on every call, which cost one query per page view here.
101+
*
99102
* @since 2.7.1 Disabled admin&CLI check to make frontend able to enable cache too
100103
*/
101104
$plugin_file = LSCWP_DIR . 'litespeed-cache.php';
102105
register_activation_hook( $plugin_file, [ __NAMESPACE__ . '\Activation', 'register_activation' ] );
103106
register_deactivation_hook( $plugin_file, [ __NAMESPACE__ . '\Activation', 'register_deactivation' ] );
104-
register_uninstall_hook( $plugin_file, __NAMESPACE__ . '\Activation::uninstall_litespeed_cache' );
105107

106108
if ( defined( 'LITESPEED_ON' ) ) {
107109
// Register purge_all actions

‎uninstall.php‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Uninstall entry point, included by WordPress when the plugin is deleted.
4+
*
5+
* Replaces register_uninstall_hook(), which read the non-autoloaded `uninstall_plugins`
6+
* option on every request. The main file is included first, as WordPress did for the
7+
* hook, so the cleanup finds its classes and constants.
8+
*
9+
* @see https://developer.wordpress.org/plugins/plugin-basics/uninstall-methods/
10+
* @package LiteSpeed
11+
*/
12+
13+
defined( 'WP_UNINSTALL_PLUGIN' ) || exit();
14+
15+
require_once __DIR__ . '/litespeed-cache.php';
16+
17+
\LiteSpeed\Activation::uninstall_litespeed_cache();

0 commit comments

Comments
 (0)