rest_output_link_wp_head

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

WordPress Version: 5.5

/**
 * Outputs the REST API link tag into page header.
 *
 * @since 4.4.0
 *
 * @see get_rest_url()
 */
function rest_output_link_wp_head()
{
    $api_root = get_rest_url();
    if (empty($api_root)) {
        return;
    }
    printf('<link rel="https://api.w.org/" href="%s" />', esc_url($api_root));
    $resource = rest_get_queried_resource_route();
    if ($resource) {
        printf('<link rel="alternate" type="application/json" href="%s" />', esc_url(rest_url($resource)));
    }
}

WordPress Version: 4.4

/**
 * Outputs the REST API link tag into page header.
 *
 * @since 4.4.0
 *
 * @see get_rest_url()
 */
function rest_output_link_wp_head()
{
    $api_root = get_rest_url();
    if (empty($api_root)) {
        return;
    }
    echo "<link rel='https://api.w.org/' href='" . esc_url($api_root) . "' />\n";
}