From 0a394fa671a8adae82f9896216ab9fffd4b41928 Mon Sep 17 00:00:00 2001 From: Marcus Quinn <6428977+marcusquinn@users.noreply.github.com> Date: Wed, 9 Apr 2025 23:56:47 +0100 Subject: [PATCH] Fix button not appearing in some WP admin themes (v1.2.3) --- CHANGELOG.md | 9 ++++++++ README.md | 7 +++++- plugin-reference-cleaner.php | 42 +++++++++++++++++++++++++++++++----- readme.txt | 7 +++++- 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b87afa9..801dc23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. +## [1.2.3] - 2023-10-05 +### Fixed +- Button not appearing in some WordPress admin themes +- Error message detection for greater theme compatibility + +### Improved +- DOM traversal to find notification elements in various themes +- Added console logging for troubleshooting + ## [1.2.2] - 2023-10-05 ### Fixed - Timeout issue during plugin activation diff --git a/README.md b/README.md index 32bfaa9..30a7e18 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Plugin Reference Cleaner Author: Marcus Quinn Author URI: https://www.wpallstars.com -Version: 1.2.2 +Version: 1.2.3 License: GPL-2.0+ ## Description @@ -47,6 +47,11 @@ If you don't have this notification perpetually showing on your /wp-admin/plugin ## Changelog +### 1.2.3 +* Fixed button not appearing in some WordPress admin themes +* Improved error message detection for greater compatibility +* Enhanced DOM traversal to find notification elements + ### 1.2.2 * Fixed timeout issue during plugin activation * Improved hook management to prevent potential infinite recursion diff --git a/plugin-reference-cleaner.php b/plugin-reference-cleaner.php index 06670e1..04c1296 100644 --- a/plugin-reference-cleaner.php +++ b/plugin-reference-cleaner.php @@ -2,7 +2,7 @@ /* * Plugin Name: Plugin Reference Cleaner * Description: Adds a "Remove Reference" button to plugin deactivation error notices, allowing users to clean up invalid plugin entries. - * Version: 1.2.2 + * Version: 1.2.3 * Author: Marcus Quinn * Author URI: https://www.wpallstars.com * License: GPL-2.0+ @@ -37,8 +37,10 @@ class Plugin_Reference_Cleaner { if (!empty($notices)) { foreach ($notices as $notice) { - if (strpos($notice, 'has been deactivated due to an error: Plugin file does not exist') !== false) { - // Extract plugin file from notice + // Look for both variations of the error message + if (strpos($notice, 'has been deactivated due to an error: Plugin file does not exist') !== false || + strpos($notice, 'deactivated due to an error: Plugin file does not exist') !== false) { + // Extract plugin file from notice using various patterns if (preg_match('/The plugin ([^ ]+)/', $notice, $match)) { $plugin_files[] = $match[1]; $has_error_notice = true; @@ -57,21 +59,51 @@ class Plugin_Reference_Cleaner {