So, I needed to disable all upgrade notifications and nags in a WordPress install. Searching the web yielded many results, most of which work and are pretty similar.

What doesn’t work

Some of what I found included code to remove wp_version_check and pre_option_update_core, like:

add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );

and

add_filter('pre_option_update_core', create_function( '$a', "return null;" ));

…but neither alone nor together work to remove WordPress Update notifications.

What Works

A lot of what I found look something like this:

function remove_core_updates () {
global $wp_version;
return(object) array(
'last_checked'=> time(),
'version_checked'=> $wp_version
);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');

This works well to remove all WordPress update notifications.

Since there is more than one way to achieve the same goal, other code samples would attempt to remove core (not theme or plugin) update notifications by using variations on pre_site_transient_update_core, such as:

add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );

or

add_filter('pre_site_transient_update_core','__return_null');

They all work to remove update notifications. There are also plugins available to achieve the same goal, but they contain the same code.

The problem with what works

Now, the code above works, but there is a problem. In an environment where debugging is turned on (such as on a local testing environment or server), the code produces a bunch of error notices in the Updates page, like so:

disable wp update notifications error notices

I aim to ship error-free code, so seeing any number of error notices is unacceptable.

The fix is to set an empty array to the updates property of the object returned by the filter to pre_site_transient_update_core, like so:

'updates' => array()

So all the code you would need to properly remove all update notifications from a WordPress install is:

function remove_core_updates () {
global $wp_version;
return(object) array(
'last_checked'=> time(),
'version_checked'=> $wp_version,
'updates' => array()
);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');

And it results in a clean, error-free Updates page.

disable-wp-update-notifications-no-errors

Notes:
1. The code should go into your theme’s functions.php file or in a plugin.

2. It is a good idea to wrap everything in an if statement, that way you could disable the notifications for certain users, environments, or whatever criteria you may have. In my case, notifications are disabled in the live/production environment but is present in local testing.