Fix critical error when plugin folder is deleted (v1.6.10)

This commit is contained in:
2025-04-12 15:06:17 +01:00
parent 24ff0f9552
commit 873ca5f272
4 changed files with 46 additions and 22 deletions

View File

@ -120,6 +120,13 @@ The plugin works by:
## Changelog ## Changelog
### 1.6.10
* Fixed critical error that could occur when a plugin folder is deleted
* Improved error handling with try/catch blocks
* Added more specific checks for the plugins page
* Enhanced compatibility with various WordPress configurations
* Made the code more defensive to prevent potential issues
### 1.6.9 ### 1.6.9
* Fixed issue with notices not appearing below WordPress error messages * Fixed issue with notices not appearing below WordPress error messages
* Improved JavaScript detection of WordPress error notices * Improved JavaScript detection of WordPress error notices

View File

@ -13,7 +13,7 @@
* Plugin Name: Fix 'Plugin file does not exist.' Notices * Plugin Name: Fix 'Plugin file does not exist.' Notices
* Plugin URI: https://wordpress.org/plugins/fix-plugin-does-not-exist-notices/ * Plugin URI: https://wordpress.org/plugins/fix-plugin-does-not-exist-notices/
* Description: Adds missing plugins to the plugins list with a "Remove Reference" link so you can permanently clean up invalid plugin entries and remove error notices. * Description: Adds missing plugins to the plugins list with a "Remove Reference" link so you can permanently clean up invalid plugin entries and remove error notices.
* Version: 1.6.9 * Version: 1.6.10
* Author: Marcus Quinn * Author: Marcus Quinn
* Author URI: https://www.wpallstars.com * Author URI: https://www.wpallstars.com
* License: GPL-2.0+ * License: GPL-2.0+
@ -48,7 +48,7 @@ if ( ! defined( 'ABSPATH' ) ) {
} }
// Define plugin constants // Define plugin constants
define( 'FPDEN_VERSION', '1.6.9' ); define( 'FPDEN_VERSION', '1.6.10' );
define( 'FPDEN_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'FPDEN_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'FPDEN_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'FPDEN_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'FPDEN_PLUGIN_FILE', __FILE__ ); define( 'FPDEN_PLUGIN_FILE', __FILE__ );
@ -396,34 +396,44 @@ class Fix_Plugin_Does_Not_Exist_Notices {
} }
/** /**
* Prevent WordPress from automatically deactivating missing plugins. * Safely prevent WordPress from automatically deactivating missing plugins.
* *
* WordPress normally deactivates plugins that don't exist and adds them to the * WordPress normally deactivates plugins that don't exist and adds them to the
* 'recently_activated' option. This filter prevents that behavior so we can * 'recently_activated' option. This filter modifies that behavior so we can
* handle the deactivation ourselves through our UI. * handle the deactivation ourselves through our UI, but only on the plugins page.
* *
* @param mixed $pre_option The value to return instead of the option value. * @param mixed $pre_option The value to return instead of the option value.
* @return mixed The original value (null) to let WordPress proceed, or an array to override. * @return mixed The original value (null) to let WordPress proceed, or an array to override.
*/ */
public function prevent_auto_deactivation( $pre_option ) { public function prevent_auto_deactivation( $pre_option ) {
// Only run on the plugins page // Safety check - if we're not in admin or if this isn't the plugins page, don't interfere
if ( ! $this->is_plugins_page() ) { if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) {
return $pre_option; return $pre_option;
} }
// Get our invalid plugins // Get current screen - only proceed if we're on the plugins page
$invalid_plugins = $this->get_invalid_plugins(); $screen = get_current_screen();
if ( ! $screen || 'plugins' !== $screen->base ) {
// If we have invalid plugins and we're on the plugins page, return an empty array return $pre_option;
// to prevent WordPress from auto-deactivating the plugins
if ( ! empty( $invalid_plugins ) ) {
// Return the current value of the option to prevent WordPress from modifying it
$recently_activated = get_option( 'recently_activated', array() );
return $recently_activated;
} }
// Otherwise, let WordPress handle it normally // Only apply our logic if we're on an admin page and specifically the plugins.php page
return $pre_option; global $pagenow;
if ( 'plugins.php' !== $pagenow ) {
return $pre_option;
}
// We're on the plugins page, so let's try to preserve the current state
try {
// Get the current value of recently_activated
$recently_activated = get_option( 'recently_activated', array() );
// Return the current value to prevent WordPress from modifying it
return $recently_activated;
} catch ( Exception $e ) {
// If anything goes wrong, let WordPress handle it normally
return $pre_option;
}
} }
} // End class Fix_Plugin_Does_Not_Exist_Notices } // End class Fix_Plugin_Does_Not_Exist_Notices

View File

@ -2,7 +2,7 @@
# This file is distributed under the GPL-2.0+. # This file is distributed under the GPL-2.0+.
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Fix 'Plugin file does not exist.' Notices 1.6.9\n" "Project-Id-Version: Fix 'Plugin file does not exist.' Notices 1.6.10\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/fix-plugin-does-not-exist-notices\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/fix-plugin-does-not-exist-notices\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"

View File

@ -5,7 +5,7 @@ Tags: plugins, missing plugins, cleanup, error fix, admin tools, plugin file doe
Requires at least: 5.0 Requires at least: 5.0
Tested up to: 6.4 Tested up to: 6.4
Requires PHP: 7.0 Requires PHP: 7.0
Stable tag: 1.6.9 Stable tag: 1.6.10
License: GPL-2.0+ License: GPL-2.0+
License URI: https://www.gnu.org/licenses/gpl-2.0.html License URI: https://www.gnu.org/licenses/gpl-2.0.html
@ -89,6 +89,13 @@ Although this plugin consumes minimal disk space, and doesn't run unless you are
== Changelog == == Changelog ==
= 1.6.10 =
* Fixed critical error that could occur when a plugin folder is deleted
* Improved error handling with try/catch blocks
* Added more specific checks for the plugins page
* Enhanced compatibility with various WordPress configurations
* Made the code more defensive to prevent potential issues
= 1.6.9 = = 1.6.9 =
* Fixed issue with notices not appearing below WordPress error messages * Fixed issue with notices not appearing below WordPress error messages
* Improved JavaScript detection of WordPress error notices * Improved JavaScript detection of WordPress error notices
@ -234,8 +241,8 @@ Although this plugin consumes minimal disk space, and doesn't run unless you are
== Upgrade Notice == == Upgrade Notice ==
= 1.6.9 = = 1.6.10 =
Fixed critical issue with WordPress automatically clearing error notices on page refresh and improved notice positioning! CRITICAL FIX: Resolves an issue that could cause a fatal error when a plugin folder is deleted. Upgrade immediately if you're experiencing the "critical error" message.
= 1.6.3 = = 1.6.3 =
Fixed Git Updater repository URLs and updated organization naming for consistent branding across all platforms! Fixed Git Updater repository URLs and updated organization naming for consistent branding across all platforms!