Opened 13 years ago
Closed 11 years ago
#20492 closed feature request (wontfix)
Improve submit_button()
Reported by: | johnbillion | Owned by: | |
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | normal | Version: | 3.4 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
The submit_button()
function takes five arguments and calling it ends up being very messy.
Example given by Scribu:
It makes for very unreadable code. For example, when I see this:
submit_button( $args['label_submit'], 'button', 'submit', false, array( 'id' => $args['id_submit'] ) )I have no idea what that
false
parameter is for, without looking up the defition for submit_button().
Plus, it's not that much shorter than writing the HTML by hand, which is clear as day:
<input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" />
Let's change this so it accepts a $text
parameter for the button text and an $attributes
parameter for everything else.
Patch coming up.
Attachments (1)
Change History (4)
#2
@
13 years ago
- Keywords has-patch needs-testing removed
- Summary changed from Switch submit_button()'s parameters to an associative array to Improve submit_button()
- Type changed from enhancement to feature request
Okay I've changed my mind on this. Clearly submit_button()
's default parameters are not appropriate 90% of the time it's used. Going through core to patch the calls to submit_button()
I can see that the 'wrap' parameter is set to 'false' most of the time, and the 'type' parameter is set to 'button' or 'secondary' most of the time.
We'd be better off introducing a couple of new submit button functions (one for each button type) and deprecating submit_button()
.
I don't really want to waste any more time on the issue though, so someone else can take this on if they like.
Here's the function patch. Now going to do up a patch for the eleventy million places it's called.