private function get_updates($assoc_args)
{
wp_version_check();
$from_api = get_site_transient('update_core');
if (!$from_api) {
return array();
}
$compare_version = str_replace('-src', '', $GLOBALS['wp_version']);
$updates = array('major' => false, 'minor' => false);
foreach ($from_api->updates as $offer) {
$update_type = Utils\get_named_sem_ver($offer->version, $compare_version);
if (!$update_type) {
continue;
}
// WordPress follow its own versioning which is roughly equivalent to semver
if ('minor' === $update_type) {
$update_type = 'major';
} else {
if ('patch' === $update_type) {
$update_type = 'minor';
}
}
if (!empty($updates[$update_type]) && !Comparator::greaterThan($offer->version, $updates[$update_type]['version'])) {
continue;
}
$updates[$update_type] = array('version' => $offer->version, 'update_type' => $update_type, 'package_url' => !empty($offer->packages->partial) ? $offer->packages->partial : $offer->packages->full);
}
foreach ($updates as $type => $value) {
if (empty($value)) {
unset($updates[$type]);
}
}
foreach (array('major', 'minor') as $type) {
if (true === \WP_CLI\Utils\get_flag_value($assoc_args, $type)) {
return !empty($updates[$type]) ? array($updates[$type]) : false;
}
}
return array_values($updates);
}