#44494 closed feature request (fixed)
Add option to hide en_US in wp_dropdown_languages()
Reported by: | swissspidy | Owned by: | swissspidy |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | I18N | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
While working on the Preferred Languages project I noticed that it's not possible to hide the English (United States)
option in wp_dropdown_languages()
.
In my case, I do not need the en_US because of the way the UI works: When I do not pick a language from the dropdown, en_US will be the default. Screenshot: https://cloudup.com/cXhxw4KPqFc
While I added a workaround using JavaScript, I think there should be a) a show_option_en_US
parameter or b) a filter (e.g. $output = apply_filters( 'wp_dropdown_languages', $output, $languages, $parsed_args )
) at the end of the function. Or perhaps even both.
Attachments (3)
Change History (13)
#2
@
6 years ago
- Keywords has-patch needs-testing added; needs-patch good-first-bug removed
- Type changed from defect (bug) to feature request
I've changed the ticket type to feature as it's not really a bug as nothing is broken here.
I've added a patch which adds an extra argument for en_US. Simple, but does the job.
#4
@
6 years ago
- Keywords needs-refresh added
- Milestone changed from Awaiting Review to 5.0
Needs updated docs and probably an other name (I'd really use show_option_...
for consistency), otherwise 👍
wp_dropdown_languages()
already supports$args
so I'm in favour of supporting another argument in that array to exclude certain locales by slug or something.languages
is also already supported though; I suppose you could reverse engineer it so you get the full list list of locales, then remove en_US and then use the updated list (minus en_US) to request as those specific locales. Not ideal, but serves as a better work around than JavaScript perhaps.Ref: https://developer.wordpress.org/reference/functions/wp_dropdown_languages/