There are a lot of question on how to disable updates and/or removing update notifications. But all solutions that disable the update also disable the update notifications.

But I want to disable the possibility to update while still being notified about available updates.

Currently I use define( 'DISALLOW_FILE_MODS', true ); Codex

The problem with this is that it not only disables the update process but also the notifications.

Edit: Okay I went down the rabbit hole a bit myself. I guess I also should clarify that I am not (only) talking about core updates but also plugins and themes.

If I understand it correctly this is because at /wp-admin/includes/update.php:250 the function returns early.

So I see two options:

  • re-add the update_pluginsoption which kind of defeats the purpose plus I am not sure of the side effects
  • add my own hook to admin_init kind of replicating wp_plugin_update_rows. I tried that but it still doesn’t look all the same. There seems to be some more to it, also it doesn’t feel like a very clean way to do this.

EDIT: There is a ticket covering this issue in case you feel like working on it: https://core.trac.wordpress.org/ticket/25219

1
1

Add the following code in your child theme’s functions.php or package it as a custom plugin to easily enable/disable:

add_action( 'wp_before_admin_bar_render', 'wpse161696_toolbar_menu' );
add_action( 'admin_menu', 'wpse161696_updates' );

function wpse161696_toolbar_menu() { // Remove update menu item from the toolbar
    global $wp_admin_bar;
    $wp_admin_bar -> remove_menu( 'updates' );
}

function wpse161696_updates() { // Remove all updating related functions
    remove_submenu_page( 'index.php', 'update-core.php' ); // Remove Update submenu
    // Redirect to Dashboard if update page is accessed
    global $pagenow;
    $page = array(
        'update-core.php',
        'update.php',
        'update.php?action=upgrade-plugin'
        );
    if ( in_array( $pagenow, $page, true ) ) {
        wp_redirect( admin_url( 'index.php' ), 301 );
        // wp_die( 'Updates are disabled.' ); // An error message can be displayed instead
        exit;
    }
}

This should give you something to work with. It removes the update links from the sidebar and toolbar in the Dashboard while leaving the update notifications on.

However, the update now will still show under each plugin which would allow the user to perform updates:

enter image description here

A solution to this is to hide the link via CSS. I couldn’t quite get that part working, but given that this question is very old, I didn’t want to waste time on it either. I felt this question needed some closure to it.

Leave a Reply

Your email address will not be published. Required fields are marked *