plugin-update-checker icon indicating copy to clipboard operation
plugin-update-checker copied to clipboard

How to do a really automatic plugin update

Open carlosGedesprin opened this issue 3 years ago • 5 comments

I'm not familiar with this plugin but it seems to tick all my boxes, so thanks YahnisElsts to offer it. One of the things I'm looking for is a way to update my plugin without the need of "human intervention". I would like my plugin to detect if a new version is available and if so install it silently. Am I a fool?

carlosGedesprin avatar Apr 04 '22 15:04 carlosGedesprin

That is technically possible, but this update checker doesn't provide it as a built-in feature. Instead, you would need to use some custom code to enable fully automatic updates for your plugin. WordPress has a few filters for that. See the Configuring Automatic Background Updates page for more information. The section "Plugin & Theme Updates via Filter" is particularly relevant:

https://wordpress.org/support/article/configuring-automatic-background-updates/#plugin-theme-updates-via-filter

YahnisElsts avatar Apr 04 '22 16:04 YahnisElsts

Thanks you so much for this info. As a suggestion, it could be great to improve so good plugin library with an option who does this. Unfortunately I'm not very good with WP plugins otherwise I would offer to do it.

carlosGedesprin avatar Apr 04 '22 16:04 carlosGedesprin

That has been suggested before in #121. Personally, I still think it seems too simple to be worth adding as an option: if someone knows enough about PHP and plugin development to successfully set up and use a custom update checker, they can probably write 4-5 lines of code to enable automatic background updates.

That said, I'll add this idea to the list of possible future enhancements.

YahnisElsts avatar Apr 05 '22 14:04 YahnisElsts

Actually, WordPress built-in automatic update does work for me.

But. Enable/Disable auto-update link (on Plugins page) does not appear (after first install or until first successful get-metadata, not sure now) until clicking on plugin "Check For Updates" or after first automatic update check (12h).

ddur avatar Apr 22 '22 18:04 ddur

Activating (forcing) automatic updates is as simple as adding your plugin to array of automatic update basenames.

	$auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
	if ( ! in_array( $plugin->get_basename(), $auto_updates, true ) ) {
		do something;
	}

Unfortunately I deleted update code, can't remember details. Because I decided to leave auto-update decision to plugin administrators, and just show warning notice when auto-update is not enabled.

ddur avatar Apr 22 '22 18:04 ddur