Allow for wp_nonce_field, wp_referrer_field and wp_original_referer_field be able to return output. Fixes #3628 props robmil.

git-svn-id: http://svn.automattic.com/wordpress/trunk@7323 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2008-03-15 22:44:34 +00:00
parent a7f441525e
commit 5cd2e835d8
1 changed files with 23 additions and 8 deletions

View File

@ -974,26 +974,41 @@ function wp_nonce_url( $actionurl, $action = -1 ) {
} }
function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true ) { function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
$name = attribute_escape( $name ); $name = attribute_escape( $name );
echo '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />'; $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
if ( $echo )
echo $nonce_field;
if ( $referer ) if ( $referer )
wp_referer_field(); wp_referer_field( $echo );
return $nonce_field;
} }
function wp_referer_field() { function wp_referer_field( $echo = true ) {
$ref = attribute_escape( $_SERVER['REQUEST_URI'] ); $ref = attribute_escape( $_SERVER['REQUEST_URI'] );
echo '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />'; $referer_field = '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />';
if ( wp_get_original_referer() ) { if ( wp_get_original_referer() ) {
$original_ref = attribute_escape( stripslashes( wp_get_original_referer() ) ); $original_ref = attribute_escape( stripslashes( wp_get_original_referer() ) );
echo '<input type="hidden" name="_wp_original_http_referer" value="'. $original_ref . '" />'; $referer_field .= "\n".'<input type="hidden" name="_wp_original_http_referer" value="'. $original_ref . '" />';
} }
if ( $echo )
echo $referer_field;
return $referer_field;
} }
function wp_original_referer_field() { function wp_original_referer_field( $echo = true ) {
echo '<input type="hidden" name="_wp_original_http_referer" value="' . attribute_escape( stripslashes( $_SERVER['REQUEST_URI'] ) ) . '" />'; $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . attribute_escape( stripslashes( $_SERVER['REQUEST_URI'] ) ) . '" />';
if ( $echo )
echo $orig_referer_field;
return $orig_referer_field;
} }