public function getWpCli()
{
$wpCliName = "wp-cli-{$this->wpCliVersion}.phar";
$wpCliPath = sys_get_temp_dir() . '/' . $wpCliName;
$wpCliTmpPath = $wpCliPath . '.tmp';
if (!file_exists($wpCliPath) || $this->wpCliVersion === "latest-stable" && $this->fileIsOlderThanDays($wpCliPath, 1)) {
$pharResource = @fopen($this->getWpCliDownloadUrl(), 'r');
if (!$pharResource) {
return $wpCliPath;
// we're probably offline or there was some kind of network error
}
file_put_contents($wpCliTmpPath, $pharResource);
if ($this->wpCliVersion === "latest-stable" && !$this->checkLatestStableChecksum($wpCliTmpPath)) {
trigger_error("Wrong checksum of WP-CLI PHAR", E_USER_NOTICE);
} else {
rename($wpCliTmpPath, $wpCliPath);
}
}
return $wpCliPath;
}