wp_original_referer_field

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

WordPress Version: 6.2

/**
 * Retrieves or displays original referer hidden field for forms.
 *
 * The input name is '_wp_original_http_referer' and will be either the same
 * value of wp_referer_field(), if that was posted already or it will be the
 * current page, if it doesn't exist.
 *
 * @since 2.0.4
 *
 * @param bool   $display      Optional. Whether to echo the original http referer. Default true.
 * @param string $jump_back_to Optional. Can be 'previous' or page you want to jump back to.
 *                             Default 'current'.
 * @return string Original referer field.
 */
function wp_original_referer_field($display = true, $jump_back_to = 'current')
{
    $ref = wp_get_original_referer();
    if (!$ref) {
        $ref = ('previous' === $jump_back_to) ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
    }
    $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr($ref) . '" />';
    if ($display) {
        echo $orig_referer_field;
    }
    return $orig_referer_field;
}

WordPress Version: 6.1

/**
 * Retrieves or displays original referer hidden field for forms.
 *
 * The input name is '_wp_original_http_referer' and will be either the same
 * value of wp_referer_field(), if that was posted already or it will be the
 * current page, if it doesn't exist.
 *
 * @since 2.0.4
 *
 * @param bool   $echo         Optional. Whether to echo the original http referer. Default true.
 * @param string $jump_back_to Optional. Can be 'previous' or page you want to jump back to.
 *                             Default 'current'.
 * @return string Original referer field.
 */
function wp_original_referer_field($echo = true, $jump_back_to = 'current')
{
    $ref = wp_get_original_referer();
    if (!$ref) {
        $ref = ('previous' === $jump_back_to) ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
    }
    $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr($ref) . '" />';
    if ($echo) {
        echo $orig_referer_field;
    }
    return $orig_referer_field;
}

WordPress Version: 5.5

/**
 * Retrieve or display original referer hidden field for forms.
 *
 * The input name is '_wp_original_http_referer' and will be either the same
 * value of wp_referer_field(), if that was posted already or it will be the
 * current page, if it doesn't exist.
 *
 * @since 2.0.4
 *
 * @param bool   $echo         Optional. Whether to echo the original http referer. Default true.
 * @param string $jump_back_to Optional. Can be 'previous' or page you want to jump back to.
 *                             Default 'current'.
 * @return string Original referer field.
 */
function wp_original_referer_field($echo = true, $jump_back_to = 'current')
{
    $ref = wp_get_original_referer();
    if (!$ref) {
        $ref = ('previous' === $jump_back_to) ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
    }
    $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr($ref) . '" />';
    if ($echo) {
        echo $orig_referer_field;
    }
    return $orig_referer_field;
}

WordPress Version: 5.3

/**
 * Retrieve or display original referer hidden field for forms.
 *
 * The input name is '_wp_original_http_referer' and will be either the same
 * value of wp_referer_field(), if that was posted already or it will be the
 * current page, if it doesn't exist.
 *
 * @since 2.0.4
 *
 * @param bool   $echo         Optional. Whether to echo the original http referer. Default true.
 * @param string $jump_back_to Optional. Can be 'previous' or page you want to jump back to.
 *                             Default 'current'.
 * @return string Original referer field.
 */
function wp_original_referer_field($echo = true, $jump_back_to = 'current')
{
    $ref = wp_get_original_referer();
    if (!$ref) {
        $ref = ('previous' == $jump_back_to) ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
    }
    $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr($ref) . '" />';
    if ($echo) {
        echo $orig_referer_field;
    }
    return $orig_referer_field;
}

WordPress Version: 4.0

/**
 * Retrieve or display original referer hidden field for forms.
 *
 * The input name is '_wp_original_http_referer' and will be either the same
 * value of wp_referer_field(), if that was posted already or it will be the
 * current page, if it doesn't exist.
 *
 * @since 2.0.4
 *
 * @param bool   $echo         Optional. Whether to echo the original http referer. Default true.
 * @param string $jump_back_to Optional. Can be 'previous' or page you want to jump back to.
 *                             Default 'current'.
 * @return string Original referer field.
 */
function wp_original_referer_field($echo = true, $jump_back_to = 'current')
{
    if (!$ref = wp_get_original_referer()) {
        $ref = ('previous' == $jump_back_to) ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
    }
    $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr($ref) . '" />';
    if ($echo) {
        echo $orig_referer_field;
    }
    return $orig_referer_field;
}

WordPress Version: 3.9

/**
 * Retrieve or display original referer hidden field for forms.
 *
 * The input name is '_wp_original_http_referer' and will be either the same
 * value of {@link wp_referer_field()}, if that was posted already or it will
 * be the current page, if it doesn't exist.
 *
 * @since 2.0.4
 *
 * @param bool $echo Whether to echo the original http referer
 * @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to.
 * @return string Original referer field.
 */
function wp_original_referer_field($echo = true, $jump_back_to = 'current')
{
    if (!$ref = wp_get_original_referer()) {
        $ref = ('previous' == $jump_back_to) ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
    }
    $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr($ref) . '" />';
    if ($echo) {
        echo $orig_referer_field;
    }
    return $orig_referer_field;
}

WordPress Version: 3.7

/**
 * Retrieve or display original referer hidden field for forms.
 *
 * The input name is '_wp_original_http_referer' and will be either the same
 * value of {@link wp_referer_field()}, if that was posted already or it will
 * be the current page, if it doesn't exist.
 *
 * @package WordPress
 * @subpackage Security
 * @since 2.0.4
 *
 * @param bool $echo Whether to echo the original http referer
 * @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to.
 * @return string Original referer field.
 */
function wp_original_referer_field($echo = true, $jump_back_to = 'current')
{
    if (!$ref = wp_get_original_referer()) {
        $ref = ('previous' == $jump_back_to) ? wp_get_referer() : wp_unslash($_SERVER['REQUEST_URI']);
    }
    $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr($ref) . '" />';
    if ($echo) {
        echo $orig_referer_field;
    }
    return $orig_referer_field;
}