Opened 14 years ago
Closed 13 years ago
#20450 closed defect (bug) (wontfix)
wp_dropdown_categories - inconsistent use of single-quotes causes (javascript) assignment issues
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | minor | Version: | 3.3.1 |
| Component: | Template | Keywords: | has-patch |
| Focuses: | Cc: |
Description
wp_dropdown_categories outputs double-quote characters for all options (value etc) BUT single-quote characters for main select attributes - which is inconsistent.
this causes a problem when assigning output to eg. a javascript string - meaning we must perform a separate 'replace' operation first.
similarly, we already have to do a replace of all newline-characters in output for newline-backslash - in order that its multi-line output can be assigned to a javascript variable.
please could we have double-quote characters used consistently in output? ideally provision of a javascript friendly output format (ie. backslash-newline) would also be great - though my no means essential.
Attachments (1)
Change History (4)
#1
@
14 years ago
- Keywords has-patch added
Pretty easy to fix. Not sure why this was done this way, probably for easier echo'ing.
#2
in reply to:
↑ description
@
14 years ago
- Keywords close added
Replying to rcain:
please could we have double-quote characters used consistently in output? ideally provision of a javascript friendly output format (ie. backslash-newline) would also be great - though my no means essential.
I don't really like this. We use single quotes all over in core, as often it is going to be a cleaner line of PHP code to use them (for example, when using variables inside double-quoted strings). While we could make this change, it would imply that we are then committing to always using double-quotes now and in the future, for all output functions. We simply cannot commit to that.
If you want to use raw HTML output in JS, you should escape it or json-encode it.
Basic fix to rewrite the entire element to double-quote characters