I was looking at ZP Remove Customizer (tagging @anon95694377 here) that deactivates itself when i run
wp plugin update --all
.
Really this is not a bug in the plugin, but it’s all about compatibility with WP-CLI and so i wanted to share some consideration:
- Can be a good idea to collect those issues and cope with strange behaviours of WP-CLI (really at the moment it’s 99% compatible)?
- Can we fix some of them in the core?
- Can we say bye bye to WP-CLI?
Now… about the issue… the code is this:
if ($this->is_classicpress()) {
if (version_compare(classicpress_version(), '1.1', '<')) {
$this->autodeactivate('ClassicPress 1.1.x');
}
}
The problem is that $cp_version
is not defined as a global, so classicpress_version()
returns null when in command line. Examples:
> wp eval 'global $cp_version; var_dump($cp_version);'
NULL
> wp eval 'global $wp_version; var_dump($wp_version);'
string(6) "4.9.13"
If i add this to version.php it works.
$GLOBALS['cp_version'] = $cp_version;
> wp eval 'global $cp_version; var_dump($cp_version);'
string(5) "1.1.2"
Or this works too (in the plugin):
if ($this->is_classicpress()) {
if (version_compare(classicpress_version(), '1.1', '<') && !defined('WP_CLI')) {
$this->autodeactivate('ClassicPress 1.1.x');
}
}
Any consideration about it?
Simone.