Opened 15 years ago
Closed 14 years ago
#3450 closed enhancement (wontfix)
wp_return() function for echo/return logic
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | minor | Version: | 2.1 |
Component: | Administration | Keywords: | needs-patch 2nd-opinion |
Focuses: | Cc: |
Description
Elegant echo/return logic wrapper by Andy Skelton
Look at all the red in the patch!
// Implementation within function: return wp_return($func_data, $echo_flag); function wp_return($data, $echo = true) { echo ( $echo ) ? $data : ''; return $data; }
Attachments (2)
Change History (12)
#1
@
15 years ago
Just though I'd point out that this isn't the same as the code as the code it replaces (this new function always returns something, even if it echo's it first).
Not saying this is bad (I personally think it's good as you can see what a function echo'ed), just pointing out the difference.
+1
#2
in reply to:
↑ description
@
15 years ago
Replying to markjaquith:
Elegant echo/return logic wrapper by Andy Skelton
Look at all the red in the patch!
// Implementation within function: return wp_return($func_data, $echo_flag); function wp_return($data, $echo = true) { echo ( $echo ) ? $data : ''; return $data; }
As Viper007Bond says, this is wrong, it will always produce and echo and then return the same value.
The function should be as follows,
function wp_return($data, $echo = true) { if ($echo) : echo $data; else : return $data; endif; }
#5
@
15 years ago
function wp_return( $what, $echo = true ) { if ( $echo ) { echo $what; } else { return $what; } }
#6
@
15 years ago
- Keywords needs-patch added; has-patch removed
- Milestone changed from 2.3 (trunk) to 2.4 (future)
#7
@
14 years ago
- Milestone changed from 2.4 to 2.5
While i think this is a good idea, There doesnt seem much traction on implementing this, I'm going to set it to 2.5 for now, Feel free to move back to 2.4 if someone wants to do it.
Patch for trunk