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; }