wp_original_referer_field()为表格获取或显示初始上一页的隐藏字段

目录

描述

译文

为表格检索或显示初始引用页隐藏字段。

若字段已显示,则输入名称为'_wp_original_http_referer'且值与wp_referer_field() 相同,如果字段不存在,则输入名为当前页面。

原文

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.

wp_original_referer_field() 描述

用法

<?php wp_original_referer_field$echo$jump_back_to ); ?>

wp_original_referer_field() 用法

参数

$echo

(boolean) (可选) Whether to echo the original http referer.

默认值: true

$jump_back_to

(string) (可选) default is 'current'. Can be 'previous' or page you want to jump back to.

默认值: 'current'

wp_original_referer_field() 参数

返回值

(string) 

Original referer field.

wp_original_referer_field() 返回值

历史

添加于 版本: 2.0.4

wp_original_referer_field() 历史

源文件

wp_original_referer_field() 函数的代码位于 wp-includes/functions.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * 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 = '';
	if ( $echo )
		echo $orig_referer_field;
	return $orig_referer_field;
}

wp_original_referer_field() 源文件