YahnisElsts/wp-update-server

WP CLI doesnt detect updates for plugins and themes

Opened this issue · 5 comments

i run mostly my wordpress updates semi-automated with the WP-CLI
when i use this WP-CLI commands:
wp plugin update --all --dry-run
wp theme update --all --dry-run
it lists only updates for default plugins/themes, but not for those i hosted on wp-update-server.
can you confirm this? or did i configured something wrong?

Greetings :)

Make sure that you're using the latest versions of plugin-update-checker and WP-CLI. I think some older PUC releases had a bug where updates wouldn't be visible to WP-CLI, but that should be fixed in the current version.

hey,

I double checked everything.
I updated all: plugin-update-checker, wp-update-server, WP-CLI.
The plugins are now listed in CLI update list as expected!
But im still missing updates for my own themes.
additional info: i use a multisite wordpress; all of my own plugins are enabled in the main site - but in wp you cant enable all themes at once.
I included PUC in the theme's function.php.
Do you have a clue?

Greetings :)

Unfortunately, only the active theme will be able to detect updates. The update checker doesn't work when it's part of an inactive theme or plugin.

To work around that, you would need to create a separate plugin that checks for updates for all of the themes (i.e. one update checker instance per theme).

well, i tried something. maybe someone else could help this too. (i run this only actively, ie on click on a button in the backend. not all the time per page load)

if (is_multisite()) {
	$sites = get_sites();
	foreach ($sites as $site) {
		$active_theme_in_blog = get_blog_option( $site->blog_id, 'current_theme' );
		$themes = wp_get_themes( array(
			'errors'  => null,   // null: return all themes, ignoring if they have errors
			'allowed' => true,   // true: return only allowed themes for a site
			'blog_id' => $site->blog_id
		) );
		foreach ( $themes as $theme ) {
			if ( $theme->name === $active_theme_in_blog ) {
				// check update with $theme
				$MyUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
					'http://localhost/wp-update/?action=get_metadata&slug=' . $theme->template,
					$theme->get_template_directory() . '/style.css',
					$theme->template
				);
				$MyUpdateChecker->checkForUpdates();
			}
		}
	}
}

later i will try to add an own a wp-cli methodfor actively checking for theme-udpates. here is a nice piece of code what can be used for it. i think it can be well re-written to find themes and start an update-check:
https://make.wordpress.org/cli/handbook/commands-cookbook/#effectively-reusing-wp-cli-internal-apis

is there a chance that u can add wp-cli-support for plugin-update-checker and update-server?

That looks like it might not work. Just checking for updates is not enough, the update checker also needs to be active to display update notifications and install updates.

is there a chance that u can add wp-cli-support for plugin-update-checker and update-server?

What kind of CLI features are you looking for?