10

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

4
  • Really? I use that and I still see the update notification. It tells me to "Please notify the site administrator" Sep 17, 2014 at 11:58
  • I updated my question.
    – kraftner
    Sep 17, 2014 at 12:40
  • 1
    Why don't you use wpremove or infinitewp like system to keep notified for updates. With these you can still turn off updates. I use that myself.
    – Robert hue
    Sep 17, 2014 at 12:40
  • 4
    Thanks Robert for the idea, but this is just another dependency and also doesn't answer but only bypasses my problem/question.
    – kraftner
    Sep 17, 2014 at 12:42

1 Answer 1

2

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.

7
  • Thanks for having a look. But what you are doing isn't really what I was looking for. First of all hiding stuff from the menu doesn't actually remove/disable it. If you know the URL it is still there. The redirect is fragile too. DISALLOW_FILE_MODS does a lot more than just block updates. Also putting the redirect in admin_menu is the wrong place. This is clearly a core bug that needs to be fixed there. Everything else is dirty and fragile hacks. Thanks for trying anyway ;)
    – kraftner
    Aug 11, 2016 at 16:14
  • How is the redirect fragile exactly? What makes everything else dirty? Aug 19, 2016 at 2:31
  • Any updates? I'd like to know what makes the redirect fragile, an example will help me understand better. Aug 22, 2016 at 14:18
  • 1
    Basically after asking the question I found the ticket and also realised that really solving it needs changes in core. Thanks for your answer anyway - I've just upvoted it (Don't know why I didn't do so earlier). Still I'll keep this open for now, probably until the bug is fixed in core.
    – kraftner
    Aug 22, 2016 at 15:51
  • 1
    Thank you. Hopefully this will be addressed by the WordPress team in the future. Aug 22, 2016 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.