From 10f6783cdb339c0c4e9bba16d4df63d9106d0245 Mon Sep 17 00:00:00 2001 From: Marcus Quinn <6428977+marcusquinn@users.noreply.github.com> Date: Sat, 12 Apr 2025 14:43:17 +0100 Subject: [PATCH] Fix duplicate notices and optimize plugin detection (v1.6.7) --- README.md | 7 ++ assets/js/admin-scripts.js | 8 +-- fix-plugin-does-not-exist-notices.php | 64 ++++++++----------- .../fix-plugin-does-not-exist-notices.pot | 2 +- readme.txt | 13 +++- 5 files changed, 48 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 0659d6b..b582c61 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,13 @@ The plugin works by: ## Changelog +### 1.6.7 +* Fixed duplicate notices issue by removing PHP-generated notice +* Simplified notice system to only show one notice below WordPress error +* Ensured consistent terminology with "Remove Notice" text +* Optimized plugin detection with caching to improve performance +* Fixed JavaScript to correctly handle multiple error messages + ### 1.6.6 * Fixed issue with "Remove Notice" link not appearing on missing plugin rows * Fixed issue with automatic removal of plugin references without user action diff --git a/assets/js/admin-scripts.js b/assets/js/admin-scripts.js index 3dd06cc..1b2c553 100644 --- a/assets/js/admin-scripts.js +++ b/assets/js/admin-scripts.js @@ -35,14 +35,14 @@ // Add content using localized strings passed via wp_localize_script var pluginMissingText = typeof fpdenData !== 'undefined' && fpdenData.i18n && fpdenData.i18n.pluginMissing ? - fpdenData.i18n.pluginMissing : 'Plugin file missing'; - var removeReferenceText = typeof fpdenData !== 'undefined' && fpdenData.i18n && fpdenData.i18n.removeReference ? - fpdenData.i18n.removeReference : 'Remove Notice'; + fpdenData.i18n.pluginMissing : 'File Missing'; + var removeNoticeText = typeof fpdenData !== 'undefined' && fpdenData.i18n && fpdenData.i18n.removeNotice ? + fpdenData.i18n.removeNotice : 'Remove Notice'; var clickToScrollText = typeof fpdenData !== 'undefined' && fpdenData.i18n && fpdenData.i18n.clickToScroll ? fpdenData.i18n.clickToScroll : 'Click here to scroll to missing plugins'; ourNotice.innerHTML = '
To remove these notices, scroll down to each plugin .php showing "(File Missing)", and click "' + removeReferenceText + '".
' + + 'To remove these notices, scroll down to each plugin .php showing "(' + pluginMissingText + ')", and click "' + removeNoticeText + '".
' + 'This safely removes the missing active plugin reference from your database, using the standard WordPress function to update your active plugin options table with only the correct remaining installed and active plugins.
' + ''; diff --git a/fix-plugin-does-not-exist-notices.php b/fix-plugin-does-not-exist-notices.php index 9d9ea5f..185fe60 100644 --- a/fix-plugin-does-not-exist-notices.php +++ b/fix-plugin-does-not-exist-notices.php @@ -13,7 +13,7 @@ * Plugin Name: Fix 'Plugin file 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. - * Version: 1.6.6 + * Version: 1.6.7 * Author: Marcus Quinn * Author URI: https://www.wpallstars.com * License: GPL-2.0+ @@ -48,7 +48,7 @@ if ( ! defined( 'ABSPATH' ) ) { } // Define plugin constants -define( 'FPDEN_VERSION', '1.6.6' ); +define( 'FPDEN_VERSION', '1.6.7' ); define( 'FPDEN_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); define( 'FPDEN_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'FPDEN_PLUGIN_FILE', __FILE__ ); @@ -73,6 +73,13 @@ add_action( 'plugins_loaded', 'fpden_load_textdomain' ); */ class Fix_Plugin_Does_Not_Exist_Notices { + /** + * Cached list of invalid plugins. + * + * @var array + */ + private $invalid_plugins = null; + /** * Constructor. Hooks into WordPress actions and filters. */ @@ -133,8 +140,8 @@ class Fix_Plugin_Does_Not_Exist_Notices { array( 'i18n' => array( 'clickToScroll' => esc_html__( 'Click here to scroll to missing plugins', 'fix-plugin-does-not-exist-notices' ), - 'pluginMissing' => esc_html__( 'Plugin file missing', 'fix-plugin-does-not-exist-notices' ), - 'removeReference' => esc_html__( 'Remove Reference', 'fix-plugin-does-not-exist-notices' ), + 'pluginMissing' => esc_html__( 'File Missing', 'fix-plugin-does-not-exist-notices' ), + 'removeNotice' => esc_html__( 'Remove Notice', 'fix-plugin-does-not-exist-notices' ), ), ) ); @@ -166,7 +173,7 @@ class Fix_Plugin_Does_Not_Exist_Notices { 'Name' => $plugin_name . ' (File Missing)', /* translators: %s: Path to wp-content/plugins */ 'Description' => sprintf( - __( 'This plugin is still marked as "Active" in your database — but its folder and files can\'t be found in %s. Click "Remove Reference" to permanently remove it from your active plugins list and eliminate the error notice.', 'fix-plugin-does-not-exist-notices' ), + __( 'This plugin is still marked as "Active" in your database — but its folder and files can\'t be found in %s. Click "Remove Notice" to permanently remove it from your active plugins list and eliminate the error notice.', 'fix-plugin-does-not-exist-notices' ), '/wp-content/plugins/
'
),
'Version' => __( 'N/A', 'fix-plugin-does-not-exist-notices' ),
@@ -302,8 +309,9 @@ class Fix_Plugin_Does_Not_Exist_Notices {
/**
* Display admin notices on the plugins page.
*
- * Shows informational notices about missing plugins and feedback
- * messages after attempting to remove a reference.
+ * Shows feedback messages after attempting to remove a reference.
+ * The main informational notice is handled by JavaScript to position it
+ * directly below the WordPress error message.
*
* @return void
*/
@@ -329,34 +337,8 @@ class Fix_Plugin_Does_Not_Exist_Notices {
get_invalid_plugins();
-
- // Display the main informational notice if there are missing plugins.
- if ( ! empty( $invalid_plugins ) ) {
- ?>
- - - - () - -
-- - -
- -