Opened 12 years ago
Closed 8 years ago
#23477 closed defect (bug) (fixed)
r21789 creates a breaking change in behavior for get_submit_button
Reported by: | vhauri | Owned by: | afercia |
---|---|---|---|
Milestone: | 4.8 | Priority: | normal |
Severity: | normal | Version: | 3.5 |
Component: | Administration | Keywords: | has-patch |
Focuses: | docs | Cc: |
Description (last modified by )
A recent change made to get_submit_button (http://core.trac.wordpress.org/changeset/21789/trunk/wp-admin/includes/template.php) has caused an unwanted change in behavior for a button on a site I maintain. Previously, the string passed as the second argument, $type
, was matched against a switch statement with several unique cases. In the event of a non-match in the switch, the default action prior to [21789] was to assign the parameter's value as the $class
string without altering it.
The change introduced in [21789] now breaks a string into individual classes, which prevents the use of the unique class names within a string of additional class names. For example, the string button-secondary save-button action
used to generate a class string in HTML of button-secondary save-button action
, but now generates the unexpected result button save-button action
(note lack of '-secondary') because it matches against the following if check on line 1600:
if ( 'secondary' === $t || 'button-secondary' === $t )
It should be noted that the phpdoc associated with the function does not name the use case that I was employing, but that the behavior of passing in a space-separated class string has previously resulted in the string being passed through untouched (and the comment here indicates it was known and expected behavior (http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/template.php?rev=21781#L1649), and this is no longer the case. Not sure if this is worth a programmatic fix, or if it might just be worth noting in the function docblock that certain classes are now 'reserved' and cannot be passed into the $type
string.
Attachments (2)
Change History (18)
#2
@
12 years ago
- Summary changed from Change 21789 creates a breaking change in behavior for get_submit_button to Change #21789 creates a breaking change in behavior for get_submit_button
#3
@
12 years ago
- Description modified (diff)
- Summary changed from Change #21789 creates a breaking change in behavior for get_submit_button to r21789 creates a breaking change in behavior for get_submit_button
#4
@
12 years ago
Clarification of above example:
Function call:
$button_str = get_submit_button( __( 'delete selected users' ), 'button-secondary save-button action', false, false, array( 'id' => 'doaction' ) );
Expected value of $button_str
:
<input type="submit" name="" id="doaction" class="button-secondary save-button action" value="delete selected users">
Actual value of $button_str
:
<input type="submit" name="" id="doaction" class="button save-button action" value="delete selected users">
#5
@
12 years ago
- Component changed from Template to Administration
- Keywords ui-focus added
- Version changed from trunk to 3.5
#6
@
12 years ago
Still a little confused, perhaps because the ticket sounds like it's a general breakage. What I'm seeing here is that button-secondary
and secondary
will silently not come through as classes if specified in type, because they are now replaced by just using the generic button
class.
#7
@
11 years ago
Agree with Vasken. Developers should still be able to manually specify "button-secondary" - no reason to expect that it would disappear.
We should remove all references to button-secondary in calls to this function elsewhere in core and allow button-secondary as a specified class.
#9
@
11 years ago
Attaching patch that removes the skip over "button-secondary" and "secondary", and also removes the class from the argument in core buttons created using this function (which has an... odd effect of having a few empty strings passed as arguments).
As a side note, there are a decent number of hardcoded HTML buttons using those classes (which I left untouched).
@
11 years ago
Allows dev to specify arbitrarily unallowed classes, while removing those class requests in core.
#12
@
8 years ago
- Keywords close added; dev-feedback removed
- Severity changed from major to normal
I'd be in favor of closing this ticket. The CSS class button-secondary
should simply not be used, because buttons using it:
- they would be not responsive
- the focus style is wrong
- the
button
base class looks exactly the same (and responsiveness and focus are OK)
#13
follow-up:
↓ 14
@
8 years ago
For reference, the core usage of secondary
and button-secondary
was cleaned up (as suggested in allow-secondary-button-class.patch) in [35182] and [38672].
The docs, however, still mention secondary
:
submit_button()
:* @param string $type Optional. The type and CSS class(es) of the button. Core values * include 'primary', 'secondary', 'delete'. Default 'primary'
get_submit_button()
:* @param string $type Optional. The type of button. Accepts 'primary', 'secondary', * or 'delete'. Default 'primary large'.
It might be a good idea to remove it from here too.
#14
in reply to:
↑ 13
@
8 years ago
- Focuses docs added; ui removed
- Keywords ui-feedback close removed
Replying to SergeyBiryukov:
The docs, however, still mention
secondary
New patch updates the docs to only mention 'primary', 'small', and 'large'.
Could you provide a specific example, with expected and actual results? Could make it easier to understand.