Opened 17 years ago
Closed 17 years ago
#4721 closed defect (bug) (fixed)
Password-Protected Post Delivers WAI-Unfriendly Code
Reported by: | cmarshall | Owned by: | Nazgul |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | minor | Version: | 2.2.2 |
Component: | Template | Keywords: | has-patch |
Focuses: | Cc: |
Description
Very simple. The form emitted by the password-protected post (in place of the content) does not meet basic WAI guidelines (label associated with form element using the for= attribute). Normally, I would rewrite this myself, but this is generated by the core (get_the_password_form in post-template.php).
If there is a simple workaround or overload, that would be great. I will be trying to figure out if I can overload it, but it does not appear to be be possible.
This isn't actually an easy issue to address, as the label's for attribute needs a unique ID, so I am applying the following hack:
function get_the_password_form() { $id = "password_".get_the_ID(); $output = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post"> <p>' . __("This post is password protected. To view it please enter your password below:") . '</p> <p><label for="'.__($id).'">' . __("Password:") . ' <input name="post_password" id="'.__($id).'" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . __("Submit") . '" /></p> </form> '; return $output; }
Attachments (2)
Change History (7)
#1
follow-up:
↓ 2
@
17 years ago
- Keywords has-patch added
- Owner changed from anonymous to Nazgul
- Status changed from new to assigned
#2
in reply to:
↑ 1
@
17 years ago
Replying to Nazgul:
Patch adds a unique id to the label based on the given post id.
It uses a random value if no post id is given for backwards compatibility.
Interesting patch.
Could we not use the global $ID if one is not passed and assume we are in "the loop"?
Having to put all that conditional code in the template looks a bit bad as well - but I guess that is something for another ticket ;-)
Patch adds a unique id to the label based on the given post id.
It uses a random value if no post id is given for backwards compatibility.