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

WP CLI doesnt detect updates for plugins and themes #63

Open
timbadur opened this issue Mar 28, 2018 · 5 comments
Open

WP CLI doesnt detect updates for plugins and themes #63

timbadur opened this issue Mar 28, 2018 · 5 comments

Comments

@timbadur
Copy link

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 :)

@YahnisElsts
Copy link
Owner

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.

@timbadur
Copy link
Author

timbadur commented Apr 4, 2018

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 :)

@YahnisElsts
Copy link
Owner

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).

@timbadur
Copy link
Author

timbadur commented Apr 5, 2018

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?

@YahnisElsts
Copy link
Owner

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?

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

2 participants