wp_refresh_heartbeat_nonces

The timeline below displays how wordpress function wp_refresh_heartbeat_nonces has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Adds the latest Heartbeat and REST-API nonce to the Heartbeat response.
 *
 * @since 5.0.0
 *
 * @param array $response The Heartbeat response.
 * @return array The Heartbeat response.
 */
function wp_refresh_heartbeat_nonces($response)
{
    // Refresh the Rest API nonce.
    $response['rest_nonce'] = wp_create_nonce('wp_rest');
    // Refresh the Heartbeat nonce.
    $response['heartbeat_nonce'] = wp_create_nonce('heartbeat-nonce');
    return $response;
}

WordPress Version: 5.5

/**
 * Add the latest Heartbeat and REST-API nonce to the Heartbeat response.
 *
 * @since 5.0.0
 *
 * @param array $response The Heartbeat response.
 * @return array The Heartbeat response.
 */
function wp_refresh_heartbeat_nonces($response)
{
    // Refresh the Rest API nonce.
    $response['rest_nonce'] = wp_create_nonce('wp_rest');
    // Refresh the Heartbeat nonce.
    $response['heartbeat_nonce'] = wp_create_nonce('heartbeat-nonce');
    return $response;
}

WordPress Version: 5.2

/**
 * Add the latest Heartbeat and REST-API nonce to the Heartbeat response.
 *
 * @since 5.0.0
 *
 * @param array  $response  The Heartbeat response.
 * @return array The Heartbeat response.
 */
function wp_refresh_heartbeat_nonces($response)
{
    // Refresh the Rest API nonce.
    $response['rest_nonce'] = wp_create_nonce('wp_rest');
    // Refresh the Heartbeat nonce.
    $response['heartbeat_nonce'] = wp_create_nonce('heartbeat-nonce');
    return $response;
}

WordPress Version: 5.0

/**
 * Add the latest Heartbeat and REST-API nonce to the Heartbeat response.
 *
 * @since 5.0.0
 *
 * @param array  $response  The Heartbeat response.
 * @return array The Heartbeat response.
 */
function wp_refresh_heartbeat_nonces($response)
{
    // Refresh the Rest API nonce.
    $response['rest_nonce'] = wp_create_nonce('wp_rest');
    // TEMPORARY: Compat with api-fetch library
    $response['rest-nonce'] = $response['rest_nonce'];
    // Refresh the Heartbeat nonce.
    $response['heartbeat_nonce'] = wp_create_nonce('heartbeat-nonce');
    return $response;
}