[wp-trac] [WordPress Trac] #3628: Proposal: wp_nonce_field,
wp_referrer_field and wp_original_referer_field should return value
WordPress Trac
wp-trac at lists.automattic.com
Sun Jan 21 15:00:06 GMT 2007
#3628: Proposal: wp_nonce_field, wp_referrer_field and wp_original_referer_field
should return value
--------------------------+-------------------------------------------------
Reporter: BjornW | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone: 2.1
Component: Optimization | Version:
Severity: normal | Keywords: proposal, wp_nonce_field, wp_referrer_field, wp_original_referer_field
--------------------------+-------------------------------------------------
The wp_nonce_field, wp_referrer_field and wp_original_referer_field
functions should return values instead of using echo. This would be more
consistent with for instance wp_nonce_url which does return value. My
proposal is easy to implement because the default behaviour is still using
echo. If you want to get the value returned one can add the $return = TRUE
parameter and the value will be returned instead of echo'ed.
Why is this useful?
1. consistency
2. useful for building forms using vars instead of mingling PHP and HTML
e.g:
{{{
function formbuilder($formdata = NULL) {
if ( function_exists('wp_nonce_field') ) {
$nonce_field = wp_nonce_field('faces-update-face_upload', $return =
TRUE);
}
$form = '<form>';
$form .= $nonce_field;
$form .= '<input type="text" />';
$form .= '</form>'
return $form
}
}}}
Basically it enhances the way these functions can be used and therefor
also expands the possible ways of using the code, while maintaining the
old behavior. Somewhere in the future the echo functionality could be
deprecated and functions would be consistent in returning values instead
of echo'ing.
--
Ticket URL: <http://trac.wordpress.org/ticket/3628>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list