Fix notice positioning and prevent auto-clearing of error notices (v1.6.9)
This commit is contained in:
@ -120,6 +120,13 @@ The plugin works by:
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### 1.6.9
|
||||||
|
* Fixed issue with notices not appearing below WordPress error messages
|
||||||
|
* Improved JavaScript detection of WordPress error notices
|
||||||
|
* Prevented WordPress from automatically clearing error notices on page refresh
|
||||||
|
* Added multiple timing attempts to ensure notices appear correctly
|
||||||
|
* Enhanced error notice targeting for better compatibility
|
||||||
|
|
||||||
### 1.6.8
|
### 1.6.8
|
||||||
* Fixed notice positioning to appear directly below WordPress error messages
|
* Fixed notice positioning to appear directly below WordPress error messages
|
||||||
* Improved notice width to match WordPress error messages
|
* Improved notice width to match WordPress error messages
|
||||||
|
@ -10,20 +10,30 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find all notification containers first
|
// Find all notification containers first
|
||||||
var noticeContainers = document.querySelectorAll('.notice, .error, .updated');
|
var noticeContainers = document.querySelectorAll('.notice, .error, .updated, div.error');
|
||||||
var targetNotice = null;
|
var targetNotice = null;
|
||||||
|
|
||||||
// Find all error notifications about missing plugins
|
// Find all error notifications about missing plugins
|
||||||
noticeContainers.forEach(function(notice) {
|
noticeContainers.forEach(function(notice) {
|
||||||
if ((notice.textContent.includes('Plugin file does not exist') ||
|
if ((notice.textContent.includes('Plugin file does not exist') ||
|
||||||
notice.textContent.includes('has been deactivated due to an error')) &&
|
notice.textContent.includes('has been deactivated due to an error')) &&
|
||||||
notice.classList.contains('error')) {
|
(notice.classList.contains('error') || notice.classList.contains('notice-error'))) {
|
||||||
// We'll use the last matching notice as our target
|
// We'll use the last matching notice as our target
|
||||||
targetNotice = notice;
|
targetNotice = notice;
|
||||||
console.log('Found WordPress error notice:', notice.textContent);
|
console.log('Found WordPress error notice:', notice.textContent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If we didn't find a specific error notice, look for the general WordPress error at the top
|
||||||
|
if (!targetNotice) {
|
||||||
|
// Try to find the WordPress error message at the top of the page
|
||||||
|
var wpError = document.querySelector('.error:not(.below-h2), div.error:not(.below-h2), .notice-error:not(.below-h2)');
|
||||||
|
if (wpError) {
|
||||||
|
targetNotice = wpError;
|
||||||
|
console.log('Found general WordPress error notice');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we found a target notice, add our custom notice after it
|
// If we found a target notice, add our custom notice after it
|
||||||
if (targetNotice) {
|
if (targetNotice) {
|
||||||
// Check if we already added our notice
|
// Check if we already added our notice
|
||||||
@ -88,7 +98,8 @@
|
|||||||
|
|
||||||
// Try to inject notices on multiple events to ensure it works
|
// Try to inject notices on multiple events to ensure it works
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
injectNotice();
|
// Delay the initial injection to ensure WordPress has fully loaded its notices
|
||||||
|
setTimeout(injectNotice, 100);
|
||||||
|
|
||||||
// Also set up a MutationObserver to watch for dynamically added notices
|
// Also set up a MutationObserver to watch for dynamically added notices
|
||||||
var observer = new MutationObserver(function(mutations) {
|
var observer = new MutationObserver(function(mutations) {
|
||||||
@ -96,8 +107,8 @@
|
|||||||
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
|
if (mutation.addedNodes && mutation.addedNodes.length > 0) {
|
||||||
// Check if added nodes are notices or contain notices
|
// Check if added nodes are notices or contain notices
|
||||||
mutation.addedNodes.forEach(function(node) {
|
mutation.addedNodes.forEach(function(node) {
|
||||||
if (node.nodeType === 1 && (node.matches('.notice, .error, .updated') || node.querySelector('.notice, .error, .updated'))) {
|
if (node.nodeType === 1 && (node.matches('.notice, .error, .updated, div.error') || node.querySelector('.notice, .error, .updated, div.error'))) {
|
||||||
injectNotice();
|
setTimeout(injectNotice, 50); // Small delay to ensure the DOM is updated
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -113,4 +124,9 @@
|
|||||||
setTimeout(injectNotice, 500); // Delay slightly to ensure dynamic content is loaded
|
setTimeout(injectNotice, 500); // Delay slightly to ensure dynamic content is loaded
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Additional attempt after a longer delay to catch late-loading notices
|
||||||
|
window.addEventListener('load', function() {
|
||||||
|
setTimeout(injectNotice, 1000); // Longer delay as final attempt
|
||||||
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -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.8
|
* Version: 1.6.9
|
||||||
* 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.8' );
|
define( 'FPDEN_VERSION', '1.6.9' );
|
||||||
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__ );
|
||||||
@ -98,6 +98,9 @@ class Fix_Plugin_Does_Not_Exist_Notices {
|
|||||||
|
|
||||||
// Enqueue admin scripts and styles.
|
// Enqueue admin scripts and styles.
|
||||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
|
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
|
||||||
|
|
||||||
|
// Prevent WordPress from automatically deactivating missing plugins
|
||||||
|
add_filter( 'pre_option_recently_activated', array( $this, 'prevent_auto_deactivation' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -391,6 +394,37 @@ class Fix_Plugin_Does_Not_Exist_Notices {
|
|||||||
|
|
||||||
return $this->invalid_plugins;
|
return $this->invalid_plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent WordPress from automatically deactivating missing plugins.
|
||||||
|
*
|
||||||
|
* WordPress normally deactivates plugins that don't exist and adds them to the
|
||||||
|
* 'recently_activated' option. This filter prevents that behavior so we can
|
||||||
|
* handle the deactivation ourselves through our UI.
|
||||||
|
*
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
|
public function prevent_auto_deactivation( $pre_option ) {
|
||||||
|
// Only run on the plugins page
|
||||||
|
if ( ! $this->is_plugins_page() ) {
|
||||||
|
return $pre_option;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get our invalid plugins
|
||||||
|
$invalid_plugins = $this->get_invalid_plugins();
|
||||||
|
|
||||||
|
// If we have invalid plugins and we're on the plugins page, return an empty array
|
||||||
|
// 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
|
||||||
|
return $pre_option;
|
||||||
|
}
|
||||||
} // End class Fix_Plugin_Does_Not_Exist_Notices
|
} // End class Fix_Plugin_Does_Not_Exist_Notices
|
||||||
|
|
||||||
// Initialize the plugin class.
|
// Initialize the plugin class.
|
||||||
|
@ -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.8\n"
|
"Project-Id-Version: Fix 'Plugin file does not exist.' Notices 1.6.9\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"
|
||||||
|
13
readme.txt
13
readme.txt
@ -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.8
|
Stable tag: 1.6.9
|
||||||
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.9 =
|
||||||
|
* Fixed issue with notices not appearing below WordPress error messages
|
||||||
|
* Improved JavaScript detection of WordPress error notices
|
||||||
|
* Prevented WordPress from automatically clearing error notices on page refresh
|
||||||
|
* Added multiple timing attempts to ensure notices appear correctly
|
||||||
|
* Enhanced error notice targeting for better compatibility
|
||||||
|
|
||||||
= 1.6.8 =
|
= 1.6.8 =
|
||||||
* Fixed notice positioning to appear directly below WordPress error messages
|
* Fixed notice positioning to appear directly below WordPress error messages
|
||||||
* Improved notice width to match WordPress error messages
|
* Improved notice width to match WordPress error messages
|
||||||
@ -227,8 +234,8 @@ Although this plugin consumes minimal disk space, and doesn't run unless you are
|
|||||||
|
|
||||||
== Upgrade Notice ==
|
== Upgrade Notice ==
|
||||||
|
|
||||||
= 1.6.8 =
|
= 1.6.9 =
|
||||||
Improved notice positioning and appearance, with better explanatory text and more reliable error detection!
|
Fixed critical issue with WordPress automatically clearing error notices on page refresh and improved notice positioning!
|
||||||
|
|
||||||
= 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!
|
||||||
|
Reference in New Issue
Block a user