Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#33844 closed enhancement (fixed)

Add language chooser to wp-signup.php

Reported by: drewapicture's profile DrewAPicture Owned by: johnbillion's profile johnbillion
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.3
Component: Login and Registration Keywords: has-patch has-screenshots
Focuses: multisite Cc:

Description

In [33920], we added the language chooser to site-new.php for choosing the language when creating a new site in the network admin.

We should also make it possible to choose the language when registering a site via wp-signup.php.

In the attached patch, there are two important aspects to note that differ from the site-new.php implementation:

  • Only already-installed languages are available in the drop-down (implementing when-needed installation would require loading the entire languages administration API otherwise)
  • It adds a filter on the available languages for this context and simultaneously makes it possible to disable the setting output by passing an empty array

There is also logic to strip any not-installed languages before output.

Attachments (9)

33844.diff (2.5 KB) - added by DrewAPicture 9 years ago.
33844.2.diff (2.8 KB) - added by DrewAPicture 9 years ago.
33844.2_twentythirteen.png (40.2 KB) - added by DrewAPicture 9 years ago.
Twenty Thirteen w/ 33844.2.diff
33844.2_twentyfourteen.png (29.5 KB) - added by DrewAPicture 9 years ago.
Twenty Fourteen w/ 33844.2.diff
33844.2_twentyfifteen.png (36.3 KB) - added by DrewAPicture 9 years ago.
Twenty Fifteen w/ 33844.2.diff
33844.2_twentysixteen.png (53.2 KB) - added by DrewAPicture 9 years ago.
Twenty Sixteen w/ 33844.2.diff
33844.3.diff (3.4 KB) - added by DrewAPicture 9 years ago.
33844.4.diff (4.4 KB) - added by johnbillion 9 years ago.
33844.5.diff (4.0 KB) - added by DrewAPicture 9 years ago.
DRY

Download all attachments as: .zip

Change History (25)

@DrewAPicture
9 years ago

#1 @DrewAPicture
9 years ago

  • Owner set to DrewAPicture
  • Status changed from new to accepted

#2 @johnbillion
9 years ago

  • Keywords needs-screenshots added
  • Type changed from defect (bug) to enhancement
  • Version set to trunk

Let's get some screenshots of what this dropdown looks like in the last few default themes (in case the CSS needs tweaking).

#3 @DrewAPicture
9 years ago

  • Keywords needs-screenshots removed

Added screenshots for Twenty Thirteen - Sixteen. The bar in the middle of the Twenty Sixteen screenshot is an artifact from my screenshot add-on. Definitely going to need a little bit of styling help in terms of forcing the drop-down to a new line in a not-janky way, because the spicing currently is not good.

Also, you might notice that all of the other setting titles have a trailing colon. I didn't introduce one here because I figured we probably didn't want such a close approximation to an existing string. Actually makes me wonder if there are close duplicates to the others like "Site Title" etc.

#4 @DrewAPicture
9 years ago

  • Keywords dev-feedback added

I'd be interested to see input here from @lancewillett or @obenland here on best-suggestion for minimally styling the language chooser.

#5 @DrewAPicture
9 years ago

  • Component changed from Networks and Sites to Login and Registration

#6 @obenland
9 years ago

I agree, it needs some margin adjustments in pretty much all themes. Not sure what we do with dropdowns in Twenty Fifteen, but I think it should look like in the other default themes. The full-width input elements don't really work on that screen, maybe we should think about displaying them like in Twenty Thirteen.

@DrewAPicture
9 years ago

@DrewAPicture
9 years ago

Twenty Thirteen w/ 33844.2.diff

@DrewAPicture
9 years ago

Twenty Fourteen w/ 33844.2.diff

@DrewAPicture
9 years ago

Twenty Fifteen w/ 33844.2.diff

@DrewAPicture
9 years ago

Twenty Sixteen w/ 33844.2.diff

#7 @DrewAPicture
9 years ago

  • Keywords has-screenshots commit added; needs-testing dev-feedback removed

#8 @DrewAPicture
9 years ago

  • Owner changed from DrewAPicture to obenland
  • Status changed from accepted to assigned

@obenland Mind reviewing this, pretty please? :-)

#9 @johnbillion
9 years ago

  • Keywords commit removed

I think the value of $_POST['WPLANG'] should be checked against get_available_languages() and set to an empty value if it's not valid.

#10 @johnbillion
9 years ago

In fact the signup_available_languages filter would need to be called here too, in case a site has a language pack installed but the owner doesn't want new sites using it but a new user manually sets it in their $_POST request (unlikely, but it's possible).

@DrewAPicture
9 years ago

#11 @DrewAPicture
9 years ago

  • Keywords commit added
  • Owner changed from obenland to johnbillion
  • Status changed from assigned to reviewing

@johnbillion: Addressed your feedback in 33844.3.diff.

#12 @johnbillion
9 years ago

  • Keywords commit removed

This doesn't work when signing up a user account and a blog at the same time. Also the WPLANG option doesn't persist if there's an error with the form submission.

New patch coming up.

@johnbillion
9 years ago

#13 @johnbillion
9 years ago

33844.4.diff addresses the following:

  • Ensures the language value persists between page loads when entering invalid information into the signup form.
  • Uses the language option when a user is signing up for an account and a blog at the same time (visiting wp-signup.php while not logged in and both user and site creation are open).

This probably needs some DRYing at this point.

@DrewAPicture
9 years ago

DRY

#14 @DrewAPicture
9 years ago

@johnbillion: 33844.5.diff encapsulates the filter and intersect logic into signup_get_available_languages() to DRY up 33844.4.diff.

#15 @johnbillion
9 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 35152:

Introduce a language chooser to the site signup process on Multisite.

If your Multisite installation is one of the relatively few that allows new sites to be registered, either by existing users or by new visitors to your site, a 'Site Language' dropdown menu will now be presented if your network has additional languages installed. This option defaults to the value of the 'Default Language' setting on the Network Admin Settings screen, and is restricted to currently installed languages.

The languages available in this setting can be controlled via the signup_get_available_languages filter. To disable it completely, return an empty array.

Fixes #33844
Props DrewAPicture, johnbillion

#16 @johnbillion
9 years ago

  • Version changed from trunk to 4.3
Note: See TracTickets for help on using tickets.