From 68097610a214885bdea6901022ecaef6bfe2f523 Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Sat, 15 Mar 2008 22:44:34 +0000 Subject: [PATCH] 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: https://develop.svn.wordpress.org/trunk@7323 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 5076dcb945..7ce117e75d 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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 ); - echo ''; + $nonce_field = ''; + if ( $echo ) + echo $nonce_field; + 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'] ); - echo ''; + $referer_field = ''; + if ( wp_get_original_referer() ) { $original_ref = attribute_escape( stripslashes( wp_get_original_referer() ) ); - echo ''; + $referer_field .= "\n".''; } + + if ( $echo ) + echo $referer_field; + + return $referer_field; } -function wp_original_referer_field() { - echo ''; +function wp_original_referer_field( $echo = true ) { + $orig_referer_field = ''; + if ( $echo ) + echo $orig_referer_field; + + return $orig_referer_field; }