The get_preferred_from_update_core() WordPress PHP function selects the first update version from the update_core option.
Usage
$preferred_update = get_preferred_from_update_core();
Parameters
This function does not have any parameters.
More information
See WordPress Developer Resources: get_preferred_from_update_core
Examples
Display the preferred core update version
$preferred_update = get_preferred_from_update_core(); if ($preferred_update) { echo "The preferred core update version is: " . $preferred_update->current; } else { echo "No update available."; }
Check if an update is available and return true or false
function is_core_update_available() { $preferred_update = get_preferred_from_update_core(); return !empty($preferred_update); }
Display update package URL
$preferred_update = get_preferred_from_update_core(); if ($preferred_update && !empty($preferred_update->package)) { echo "Update package URL: " . $preferred_update->package; } else { echo "No update package URL available."; }
Display update response
$preferred_update = get_preferred_from_update_core(); if ($preferred_update && !empty($preferred_update->response)) { echo "Update response: " . $preferred_update->response; } else { echo "No update response available."; }
Display update version and locale
$preferred_update = get_preferred_from_update_core(); if ($preferred_update) { echo "Update version: " . $preferred_update->current . "<br>"; echo "Update locale: " . $preferred_update->locale; } else { echo "No update version and locale available."; }