Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to do a really automatic plugin update #487

Open
carlosGedesprin opened this issue Apr 4, 2022 · 5 comments
Open

How to do a really automatic plugin update #487

carlosGedesprin opened this issue Apr 4, 2022 · 5 comments

Comments

@carlosGedesprin
Copy link

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?

@YahnisElsts
Copy link
Owner

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

@carlosGedesprin
Copy link
Author

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.

@YahnisElsts
Copy link
Owner

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.

@ddur
Copy link

ddur commented Apr 22, 2022

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
Copy link

ddur commented Apr 22, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants