rudrastyh / misha-update-checker

This simple plugin does nothing, only gets updates from a custom server
124 stars 44 forks source link

Update not possible in WP Multisite unless network activated #9

Open MattFCP opened 1 year ago

MattFCP commented 1 year ago

I have tested this on several sites that are not WPMU and it works great. The only issue is, this plugin does not show update available in a WordPress Multisite unless it is network activated. In other words, it does show the update available icon in the top menu bar, but when you click on it, it shows no update available if the plugin is activated on a single site in the network.

What I have discovered is, it has to be Network Activated for it to allow you to click "Update" in the plugins list only in the Network Admin. I know it's possible for this to work on sub-sites as I've seen this done with the GeneratePress Premium plugin. I'm just wondering if you know of an easy fix for this.

bigorno commented 1 year ago

Hi @MattFCP I haven't tryed it by myself but according to the doc about transients, set_transients() is not supposed to work with networks, you should use set_site_transients() instead.

Note that the “site_” functions are essentially the same as their counterparts, but work network wide when using WordPress.

misha-update-checker.php (row 63) uses set_transient() without checking is_multisite().

set_transient( $this->cache_key, $remote, DAY_IN_SECONDS );

I giuess it could explain why it doesn't works for networks.

Maybe doing somethink like this resolves the question :

if(is_multisite()){ set_site_transient( $this->cache_key, $remote, DAY_IN_SECONDS ); } else { set_transient( $this->cache_key, $remote, DAY_IN_SECONDS ); } As I sayed I haven't tryed that for myself but I m going to do so, if it's fine I will make a pull request.