Skip to content

Commit 9e02903

Browse files
authored
Skip plugin auto-activation if plugin file doesn't exist (#332)
## What I propose adding a `file_exists()` check before calling `is_plugin_inactive()` in the `admin_footer` action inside `db.copy`. ## Why If the SQLite plugin is inactive for some reason but the `db.php` drop-in file exists, the logic automatically activates the plugin. This works only when the SQLite plugin is installed into the `plugins/` directory and throws warnings if plugin is installed into the `mu-plugins/` directory. The new guard ensures that the plugin is installed in `plugins/` before running activation logic. ## Testing 1. Install WordPress 2. Install the SQLite plugin from the .org directory 3. Activate the plugin - confirm `db.php` drop-in is created 4. Deactivate the plugin by bypassing normal logic: ``` wp option delete active_plugins ``` 6. Confirm `db.php` still exists 7. Reload WP Admin 8. Confirm the plugin is auto-activated
1 parent 7be6b9c commit 9e02903

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

db.copy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ add_action(
4646
if ( ! function_exists( 'activate_plugin' ) ) {
4747
require_once ABSPATH . 'wp-admin/includes/plugin.php';
4848
}
49-
if ( is_plugin_inactive( '{SQLITE_PLUGIN}' ) ) {
49+
50+
$plugin_path = WP_PLUGIN_DIR . '/' . '{SQLITE_PLUGIN}';
51+
52+
if ( file_exists( $plugin_path ) && is_plugin_inactive( '{SQLITE_PLUGIN}' ) ) {
5053
// If `activate_plugin()` returns a value other than null (like WP_Error),
5154
// the plugin could not be found. Try with a hardcoded string,
5255
// because that probably means the file was directly copy-pasted.

0 commit comments

Comments
 (0)