Opened 7 years ago
Closed 7 years ago
#40205 closed defect (bug) (fixed)
Interim login modal window uses front end language instead of admin language
Reported by: | johnbillion | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | I18N | Keywords: | needs-screenshots has-patch needs-testing |
Focuses: | administration | Cc: |
Description
When the interim login modal appears (for example your cookies expire or you log out in another tab), the login screen is show in the language of the site instead of the language that the user has selected for the admin area.
It should be possible to, for example, pass a ?lang=<lang>
attribute to wp-login.php
in order to specify the UI language, and use this attribute in the interim login modal URL to pass through the user's chosen admin language.
Such as URL parameter would also potentially allow for a language switcher to be added to the login screen.
Attachments (5)
Change History (14)
#1
@
7 years ago
Checks if the locale is passed through the URL in get_locale()
and returns if it's set.
#2
follow-up:
↓ 3
@
7 years ago
Thanks for the patch, @Nikschavan!
I don't think that logic should be inside get_locale()
though. Plus, there probably needs to be more robust sanitization.
We could add this to wp-settings.php
directly, however we could also leverage switch_to_locale()
inside wp-login.php
. Seems cleaner to me this way.
Perhaps we could even add a link to switch the language back to the site's locale if that makes sense.
Any thoughts?
#3
in reply to:
↑ 2
@
7 years ago
- Component changed from Login and Registration to I18N
Replying to swissspidy:
we could also leverage
switch_to_locale()
insidewp-login.php
.
This is the best approach.
#4
@
7 years ago
I have updated the patch to use switch_to_locale()
inside wp-login.php
For sanitization right now I am just using sanitize_text_field ()
will this need more sanitization for this?
#5
@
7 years ago
- Keywords has-patch added; needs-patch removed
Thanks for the patch!
A few notes:
- I think
switch_to_locale()
should happen before thelogin_init
action fires. - Should we add a
restore_previous_locale()
call for consistency? (only ifswitch_to_locale()
returns true) sanitize_text_field()
should be fine.switch_to_locale()
bails early when the locale is not invalid.
#6
@
7 years ago
Thank you for the feedback @swissspidy
I have updated the patch accordingly.
About restore_previous_locale ()
I have added them for all the switch/cases.
Example of an Arabic modal login screen showing for a user with English language admin