Closed robert81 closed 1 year ago
This is an interesting one. I am not quite sure how we can fix it.
The WP Mail SMTP plugin tries to remove all notices not related to their plugin. It does this by removing all actions registered with hooks user_admin_notices
, admin_notices
and all_admin_notices
- see the code below.
We use the all_admin_notices
to print the closing DIV tag of our wrapper with CSS class anm-notices-wrapper
. The hook doesn't run and therefore our DIV is not closed propelrly.
https://github.com/awesomemotive/WP-Mail-SMTP/blob/master/src/Admin/Area.php#L1197-L1212
/**
* Remove all non-WP Mail SMTP plugin notices from our plugin pages.
*
* @since 1.0.0
*/
public function hide_unrelated_notices() {
// Bail if we're not on our screen or page.
if ( ! $this->is_admin_page() ) {
return;
}
$this->remove_unrelated_actions( 'user_admin_notices' );
$this->remove_unrelated_actions( 'admin_notices' );
$this->remove_unrelated_actions( 'all_admin_notices' );
}
I can see two possible solutions.
network_admin_notices
hook along with the other three.What would you like to do here, @robert81?
Hi @martinkrcho,
I'm the lead developer for WP Mail SMTP plugin.
Since your plugin is managing admin notices and we are removing all other ones on our pages, I would recommend going with option 2, because there won't be any notices to manage, except our own :)
You could of course hook into our code and disable the hide_unrelated_notices
, like so:
add_action( 'network_plugin_loaded', function () {
if ( ! function_exists( 'wp_mail_smtp' ) ) {
return;
}
remove_action( 'admin_print_scripts', [ wp_mail_smtp()->get_admin(), 'hide_unrelated_notices' ] );
} );
Have a nice day!
/cib
Branch issue-63-WP_Mail_SMTP_settings_disappear_on_Multisite_with_ANM created!
You could of course hook into our code and disable the
hide_unrelated_notices
Thanks for the advice, @capuderg . We're going to add this to our plugin.
As I said, we would prefer option 2, because this change will display all admin notices on our plugin pages (because you are removing the hook where we originally remove all other admin notices). This would actually make our user's experience worse because they would see all the admin notices on our admin pages by default if your plugin would be active.
With the code above I just wanted to provide a way on how to hook in our code, if you'll ever need it in the future.
I see. No problem.
How about my suggestion number 1?
Get in touch with plugin authors and ask them to clear
network_admin_notices
hook along with the other three.
Is there any reason why you're not removing actions hooked into network_admin_notices
?
Oh, I misunderstood you first point. You are suggesting that we also clear network_admin_notices
, like so:
$this->remove_unrelated_actions( 'network_admin_notices' );
?
I'll open a GH issue in our repository, and if everything is OK after our testing, we'll add this to the next plugin update (should be around early/mid April -> but no promises on the actual date :) ).
Thanks, @capuderg . For now we are going to stop hiding notices on WP Mail SMTP's admin pages.
Hi @martinkrcho,
I'm the developer for WP Mail SMTP plugin.
We have implemented your first suggestion about clearing network_admin_notices
hook.
We plan to release our 3.4 version with this implementation the next week.
It would be great if you can remove this fix in your upcoming release.
Thank you @alexander-sakal
We will indeed take care of this in the next release.
/cib
Branch issue-63-WP_Mail_SMTP_settings_disappear_on_Multisite_with_ANM created!
@DannyWPWS @robert81 Performed basic checks for this one and can confirm it's solved in the latest build.
1) Install WP Mail SMTP on the network 2) Install ANM 3) The settings do not load up:
4) Without ANM all works well:
Let's fix this and also test it on the single site once at it.