- Feb 26, 2020
- 341
- 1,043
- 100
A question to you!
What plugin do you use to remove all these nasty notices?
or do you do that by a certain code?
PHP:
// Remove all admin notice checks to improve admin loading speed and overall UI
add_action('admin_head', function() {
// Set our global variables
global $pagenow;
// If $pagenow is not index.php
if ($pagenow !== 'index.php') {
// Remove all action calls for admin_notices
remove_all_actions('admin_notices');
}
}, 1);
There is a simple conditional check in there. You can tweak it how you need if you know how.
In my setup, I have admin notices only to show on a certain url to a certain user ID.
In this way they never show to anyone else, and they only show to me, if I visit a certain page.
Let me know if it speeds up your admin!!! Honestly, it has been the most speed increasing my backend, beside hosting/server itself. Most plugins make calls to make an admin notice, and Wordpress itself does. These runs so many checks on every page almost. And this snippet puts that to a stop as far as I know. I've never went through the code code to see if it can be done deeper or something is missed. There are a few plugins that still render notices, I think 1 or 2 in my experience. This snippet also make use of WP friendly filter "remove_all_actions".