_upgrade_cron_array() WP 2.1.0
Upgrade a Cron info array.
This function upgrades the Cron info array to version 2.
This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.
No Hooks.
Return
Array
. An upgraded Cron info array.
Usage
_upgrade_cron_array( $cron );
- $cron(array) (required)
- Cron info array from _get_cron_array().
Changelog
Since 2.1.0 | Introduced. |
Code of _upgrade_cron_array() upgrade cron array WP 5.7
function _upgrade_cron_array( $cron ) {
if ( isset( $cron['version'] ) && 2 == $cron['version'] ) {
return $cron;
}
$new_cron = array();
foreach ( (array) $cron as $timestamp => $hooks ) {
foreach ( (array) $hooks as $hook => $args ) {
$key = md5( serialize( $args['args'] ) );
$new_cron[ $timestamp ][ $hook ][ $key ] = $args;
}
}
$new_cron['version'] = 2;
update_option( 'cron', $new_cron );
return $new_cron;
}