-
Notifications
You must be signed in to change notification settings - Fork 404
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
[Feature] Check for updates if WP-CLI checks for updates #558
Comments
I believe the first part can be covered by checking if the |
@YahnisElsts thanks for getting back to me! I asked in the cli slack channel and got the following answer for how to get information about the current WP-CLI command:
Based on that, I played around a bit: /**
* Check for WP-CLI commands running wp_update_plugins
*/
function isWpCliUpdateCheck(): bool
{
if (!defined('WP_CLI') || !WP_CLI) return false;
// get the args of the current command
$args = \WP_CLI::get_runner()->arguments;
// convert the args array back to the command string
$command = implode(' ', $args);
// check for wp-cli commands that are known to trigger a check for plugin updates
return match ($command) {
'plugin list' => true,
'plugin status' => true,
'cron event run wp_version_check' => true,
// 'foo bar' => true, ???
default => false
};
}
if (isWpCliUpdateCheck()) {
// ... run the update checker
} While this technically works, it will be a pain to maintain. These commands could change at any time, not even mentioning theme updates... So I think we should continue to look for a reliably way to detect |
Actually, re-reading your comment:
Maybe we could get away with combining the two?
|
It looks like WP-CLI provides a This could use more testing - give it a try. |
Works like a charm! I tested it with two plugins – one managed by WordPress (relevanssi), one managed by plugin update checker (rh-admin-utils). Here is the relevant command output: Before updating puc, rh-admin-utils didn't detect that there was a new version available, after updating puc it detected the new version: Before
After
Also, sorry for keeping you waiting for so long... your help means a lot! |
Sounds good. I've made a new release (5.4) that includes this feature, so I'll close the issue now. |
Hi there!
The Problem
The WP-CLI command
wp plugin ...
has a few commands where they automatically check for plugin updates, for example:wp plugin status
wp plugin list
I just noticed that Plugin Update Checker doesn't check for updates if these commands are being executed.
Proposed Solution
Both these commands call
wp_update_plugins
directly if being executed.Would it be possible to automatically check for updates in Plugin Update Checker as well, if one of those commands is being executed? I just checked and it seems like in
wp_update_plugins
there is no action being triggered. So it might be hard to achieve updates based on only that function.Alternatives considered
Implement a custom wp cli command in userland, something like this:
That works, but it would be amazing to get this out of the box.
The text was updated successfully, but these errors were encountered: