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

  • Really? I use that and I still see the update notification. It tells me to "Please notify the site administrator" – Stephen Harris Sep 17 '14 at 11:58
  • I updated my question. – kraftner Sep 17 '14 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 '14 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 '14 at 12:42
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.

  • 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 '16 at 16:14
  • How is the redirect fragile exactly? What makes everything else dirty? – Ethan Jinks O'Sullivan Aug 19 '16 at 2:31
  • Any updates? I'd like to know what makes the redirect fragile, an example will help me understand better. – Ethan Jinks O'Sullivan Aug 22 '16 at 14:18
  • Sorry for not getting back. "dirty" refers to the fact that this should be fixed in core. My wording carried too much disappointment about the fact that it isn't, sorry about that. "Fragile" refers to the fact that this assumes too much like page URLs and might break with WP changes (e.g. shiny updates just happened, I don't know if that might change anything) Finally my main concern is that I want to use DISALLOW_FILE_MODS for other reasons too, e.g. disabling the Editor. But setting it true triggers this issue. Sorry, the question didn't make that clear. – kraftner Aug 22 '16 at 15:06
  • I see. So this question wouldn't be solved to your requirements since it would require tweaking the core files. – Ethan Jinks O'Sullivan Aug 22 '16 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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