Commit Graph

351 Commits

Author SHA1 Message Date
Sergey Biryukov
e9599bc7b5 Email: Don't send notifications for site or network admin email address change to the default 'admin_email' value.
Props tigertech, MattyRob, seanchayes.
Fixes #42693.
Built from https://develop.svn.wordpress.org/trunk@42570


git-svn-id: http://core.svn.wordpress.org/trunk@42399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-01-23 13:45:32 +00:00
Gary Pendergast
aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
John Blackbourn
50948669eb Users: Revert [41613], [41614], and [41623] as this feature needs some more work.
See #38741

Built from https://develop.svn.wordpress.org/trunk@41753


git-svn-id: http://core.svn.wordpress.org/trunk@41587 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 22:17:46 +00:00
Jeremy Felt
f646f0aa47 Multisite: Only query for one site in domain_exists().
`get_sites()` queries for a maximum of 100 records by default. In `domain_exists()`, we only use one.

A previous commit, [41736], has this same commit message but applies to `get_blog_id_from_url()` and #42073 instead.

Props danieltj, spacedmonkey.
Fixes #42072.

Built from https://develop.svn.wordpress.org/trunk@41738


git-svn-id: http://core.svn.wordpress.org/trunk@41572 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 16:26:45 +00:00
Jeremy Felt
19e9de3367 Multisite: Only query for one site in domain_exists().
`get_sites()` queries for a maximum of 100 records by default. In `domain_exists()`, we only use one.

Props danieltj, spacedmonkey.
Fixes #42072.

Built from https://develop.svn.wordpress.org/trunk@41736


git-svn-id: http://core.svn.wordpress.org/trunk@41570 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 16:11:51 +00:00
Felix Arntz
1130241bbd Multisite: Replace calls to refresh_blog_details() with clean_blog_cache().
Fixes #42077. See #40201.

Built from https://develop.svn.wordpress.org/trunk@41717


git-svn-id: http://core.svn.wordpress.org/trunk@41551 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 19:05:46 +00:00
John Blackbourn
2ad86e1e82 Docs: Correct some @since MU notation that was broken in [41200].
Every function introduced by MU was introduced in 3.0.0 as this was when MU was merged.

See #41509

Built from https://develop.svn.wordpress.org/trunk@41714


git-svn-id: http://core.svn.wordpress.org/trunk@41548 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 17:44:48 +00:00
Sergey Biryukov
190929cb6c Multisite: Change IP references in new site or user notifications to IP address for clarity.
Props gk.loveweb, bradparbs.
See #40382.
Built from https://develop.svn.wordpress.org/trunk@41705


git-svn-id: http://core.svn.wordpress.org/trunk@41539 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-03 13:13:47 +00:00
John Blackbourn
4a16295dc5 Docs: Standardise the format used for documenting parameters passed by reference.
See #35974, #41017

Built from https://develop.svn.wordpress.org/trunk@41688


git-svn-id: http://core.svn.wordpress.org/trunk@41522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 22:14:46 +00:00
Jeremy Felt
5ccf8eebb7 Multisite: Deprecate is_user_option_local().
`is_user_option_local()` was added during MU development and used for a handful of changesets before the code using it was removed again. It has not been used by MU or core since nor is it widely used elsewhere.

Fixes #41697.
Props bnap00, jeremyfelt.

Built from https://develop.svn.wordpress.org/trunk@41668


git-svn-id: http://core.svn.wordpress.org/trunk@41502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 03:38:45 +00:00
Jeremy Felt
abdfe59c28 Multisite: Use get_current_blog_id() instead of $wpdb->blogid.
`get_current_blog_id()` is more appropriate for determining the ID of the current site in most cases. This eliminates the need for the global `$wpdb` in several functions and is better than the implicit global used in admin pages.

Props bnap00, spacedmonkey.
Fixes #41684.

Built from https://develop.svn.wordpress.org/trunk@41661


git-svn-id: http://core.svn.wordpress.org/trunk@41495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 01:44:47 +00:00
John Blackbourn
50a7d2b121 Options, Meta APIs: Require a confirmation link in an email to be clicked when a user attempts to change the network
admin email address on Multisite.

This mirrors the same functionality for the site admin email address and user profile email address.

Fixes #41254

Built from https://develop.svn.wordpress.org/trunk@41617


git-svn-id: http://core.svn.wordpress.org/trunk@41452 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-27 14:17:45 +00:00
John Blackbourn
807bc5a6c9 Users: Introduce the concept of a large site in order to speed up the Users screen when there are many users.
Calling the `count_users()` function is expensive, regardless of the counting strategy that's used, and it gets
slower the more users there are on a site. In order to speed up the Users screen in the admin area, calling
`count_users()` can be avoided entirely while still displaying the total count for users.

This introduces some new functions:

* `wp_is_large_user_count()`
* `wp_get_active_user_count()`
* `wp_update_active_user_count()`

A corresponding `wp_is_large_user_count` filter is also introduced.

Props tharsheblows, johnbillion

Fixes #38741

Built from https://develop.svn.wordpress.org/trunk@41613


git-svn-id: http://core.svn.wordpress.org/trunk@41448 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-27 13:04:47 +00:00
Felix Arntz
85712eb281 Multisite: Fix documentation issues for domain_exists().
Props stevenlinx.
Fixes #41619.

Built from https://develop.svn.wordpress.org/trunk@41596


git-svn-id: http://core.svn.wordpress.org/trunk@41429 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-26 00:12:45 +00:00
John Blackbourn
9aeedde6ae Multisite: Correct the docs for maybe_add_existing_user_to_blog().
See #41017

Built from https://develop.svn.wordpress.org/trunk@41552


git-svn-id: http://core.svn.wordpress.org/trunk@41385 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-21 12:28:44 +00:00
Felix Arntz
70daaadc6a Multisite: Remove an unnecessary if clause wrapping the added_existing_user filter.
This was accidentally introduced in [41125]. Since the `added_existing_user` filter has historically accepted either `true` or a `WP_Error` object, the clause is not necessary here. The doc block has been adjusted to account for the new possible `WP_Error` condition.

Fixes #41101.

Built from https://develop.svn.wordpress.org/trunk@41324


git-svn-id: http://core.svn.wordpress.org/trunk@41155 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-30 19:53:45 +00:00
John Blackbourn
28eda6f4bc General: Improve terminology used when referring to installations of WordPress and its extensions.
"Install" is not a noun, and while it might be acceptable to use the verb as a noun, it is not correct. Using the correct
noun, "installation", increases clarity, especially for non-native English speakers.

This change fixes the usage in user-facing text and in developer documentation.

Fixes #41620

Built from https://develop.svn.wordpress.org/trunk@41289


git-svn-id: http://core.svn.wordpress.org/trunk@41129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-22 11:52:48 +00:00
Felix Arntz
473e1ba73b Multisite: Remove references to $wpdb->siteid and use get_current_network_id() instead.
Props sathyapulse, spacedmonkey.
Fixes #41507.

Built from https://develop.svn.wordpress.org/trunk@41242


git-svn-id: http://core.svn.wordpress.org/trunk@41082 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-12 13:11:43 +00:00
Felix Arntz
820d3973a3 Multisite: Rename internal $site_id variables referencing networks to $network_id.
This change improves code clarity by using the current naming conventions for networks.

Props lemacarl.
Fixes #41510.

Built from https://develop.svn.wordpress.org/trunk@41241


git-svn-id: http://core.svn.wordpress.org/trunk@41081 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-12 12:48:47 +00:00
John Blackbourn
c26b735c8a Multisite: Clarify descriptions of the wpmu_signup_blog_notification() and wpmu_signup_user_notification() functions.
See #41017

Built from https://develop.svn.wordpress.org/trunk@41230


git-svn-id: http://core.svn.wordpress.org/trunk@41070 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-04 14:21:43 +00:00
Felix Arntz
7e2ca92e69 Multisite: Introduce a can_add_user_to_blog filter to prevent adding a user to a site.
Under certain circumstances, it can be necessary that a user should not be added to a site, beyond the restrictions that WordPress core applies. With the new `can_add_user_to_blog` filter, plugin developers can run custom checks and return an error in case of a failure, that will prevent the user from being added.

The user-facing parts and the REST API route that interact with `add_user_to_blog()` have been adjusted accordingly to provide appropriate error feedback when a user could not be added to a site. Furthermore, two existing error feedback messages in the site admin's "New User" screen have been adjusted to properly show inside an error notice instead of a success notice.

Props jmdodd.
Fixes #41101.

Built from https://develop.svn.wordpress.org/trunk@41225


git-svn-id: http://core.svn.wordpress.org/trunk@41065 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-03 21:41:45 +00:00
Drew Jaynes
0401cee8b3 Docs: Reduce confusion in @since MU notationss by indicating the WP version (3.0.0) the code was merged into core while retaining the original context.
Props sathyapulse.
Fixes #41509.

Built from https://develop.svn.wordpress.org/trunk@41200


git-svn-id: http://core.svn.wordpress.org/trunk@41040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-01 20:44:43 +00:00
John Blackbourn
b9b4776800 Options, Meta APIs: Send a notification to the old admin email address when the site admin email or network admin email address is changed.
This reduces the chances of a site compromise going unnoticed, in the same way that the same notifications for user account email address changes reduces the chances of a user account compromise going unnoticed.

Props MatheusGimenez, johnbillion

Fixes #39117

Built from https://develop.svn.wordpress.org/trunk@41164


git-svn-id: http://core.svn.wordpress.org/trunk@41004 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-27 02:24:42 +00:00
Felix Arntz
df8506f523 Multisite: Use get_network_option() for language in wpmu_create_blog().
Before this changeset, the language of a new site would always result in the language of the current network, regardless of the `$site_id` parameter passed that actually determines the network for the site. Now the correct `WPLANG` value is used in such cases.

Alongside this change, a few minor documentation changes around the function have been made to account for the current naming conventions of sites and networks.

Props spacedmonkey.
Fixes #40503.

Built from https://develop.svn.wordpress.org/trunk@41058


git-svn-id: http://core.svn.wordpress.org/trunk@40908 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-14 21:08:43 +00:00
Drew Jaynes
faab7f4533 Docs: Improve and clarify the DocBlock summary for wpmu_log_new_registrations().
Props daymobrew.
Fixes #39922.

Built from https://develop.svn.wordpress.org/trunk@40951


git-svn-id: http://core.svn.wordpress.org/trunk@40801 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-06-26 18:05:41 +00:00
Drew Jaynes
fafa1dfa07 Docs: Add more complete documentation about expected values in the $meta parameter for wpmu_create_blog().
See #41017.

Built from https://develop.svn.wordpress.org/trunk@40930


git-svn-id: http://core.svn.wordpress.org/trunk@40780 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-06-25 05:48:45 +00:00
Felix Arntz
0f4725a0e3 Multisite: Adjust site count of the correct network after having created a new site.
Prior to this change, after creating a site, the network site count was always refreshed on the current network, regardless of whether the site was created on a different network. With the recent changes, particularly [40591], it is now possible to update the site count for a specific `$network_id`, so this changeset makes use of the new parameter.

Fixes #38699.

Built from https://develop.svn.wordpress.org/trunk@40612


git-svn-id: http://core.svn.wordpress.org/trunk@40482 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-10 23:22:42 +00:00
Jeremy Felt
5b3d397133 Multisite: Check only valid looking emails against banned domain list.
If an email address is missing an `@`, we can't assume enough to check it against a list of domain names.

Additional validation of email should happen in `is_email()` before being passed to `is_email_address_unsafe()`.

Fixes #39915.

Built from https://develop.svn.wordpress.org/trunk@40595


git-svn-id: http://core.svn.wordpress.org/trunk@40465 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-09 16:55:40 +00:00
Jeremy Felt
3600dc562e Multisite: Validate email before checking against banned domains.
Previously, an invalid email could result in an undefined index when attempting to determine the email domain.

Props ocean90.
See #39915.

Built from https://develop.svn.wordpress.org/trunk@40594


git-svn-id: http://core.svn.wordpress.org/trunk@40464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-09 16:33:46 +00:00
Felix Arntz
d92dbd24fc Multisite: Add $network_id parameter to wp_maybe_update_network_user_counts().
This allows calling the function for a specific network correctly, for example after a user has been created for it or been removed from it.

Fixes #40385. See #38699.

Built from https://develop.svn.wordpress.org/trunk@40593


git-svn-id: http://core.svn.wordpress.org/trunk@40463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-09 16:08:43 +00:00
Felix Arntz
314f2aecec Multisite: Add missing documentation for new $network_id parameter of wp_maybe_update_network_site_counts().
This was overlooked in [40591].

See #40384.

Built from https://develop.svn.wordpress.org/trunk@40592


git-svn-id: http://core.svn.wordpress.org/trunk@40462 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-09 16:02:46 +00:00
Felix Arntz
93b8b9bb4e Multisite: Add $network_id parameter to wp_maybe_update_network_site_counts().
This allows calling the function for a specific network correctly, for example after a site has been created for it or been removed from it.

Fixes #40384. See #38699.

Built from https://develop.svn.wordpress.org/trunk@40591


git-svn-id: http://core.svn.wordpress.org/trunk@40461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-09 16:00:44 +00:00
Felix Arntz
039d49a68a Multisite: Add $network_id parameter to wp_is_large_network().
Now that `get_blog_count()` and `get_user_count()` both support passing a `$network_id` parameter (see [40370] and [40371]), similar functionality is now available for `wp_is_large_network()`. In addition, the filter `wp_is_large_network` now accepts the network ID as its fourth parameter.

This changeset furthermore introduces unit tests for the `wp_is_large_network()` function and its filter.

Fixes #40489.

Built from https://develop.svn.wordpress.org/trunk@40590


git-svn-id: http://core.svn.wordpress.org/trunk@40460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-09 15:51:47 +00:00
Felix Arntz
a3797875bf Multisite: Introduce minimum_site_name_length filter.
Prior to this change, the minimum site name length checked in `wpmu_validate_blog_signup()` was set to a fixed value of 4. The new filter allows tweaking this value, as there may be cases where shorter site names may be required.

Fixes #39676.

Built from https://develop.svn.wordpress.org/trunk@40589


git-svn-id: http://core.svn.wordpress.org/trunk@40459 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-09 14:59:47 +00:00
Felix Arntz
9c8bf59842 Multisite: Add $network_id parameter to wp_update_network_counts().
After the `$network_id` parameter has been introduced for `wp_update_network_site_counts()` in [40484] and `wp_update_network_user_counts()` in [40485], the new parameter can now also be used on the wrapping function.

Fixes #40386. See #38699.

Built from https://develop.svn.wordpress.org/trunk@40486


git-svn-id: http://core.svn.wordpress.org/trunk@40362 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-04-20 00:27:42 +00:00
Felix Arntz
79be8dff6d Multisite: Add $network_id parameter to wp_update_network_user_counts().
Using the new parameter, it is now possible to update the user count on a network different from the current one. While the count itself is technically a global user count and not network-wide, it is stored on each individual network, and the new parameter provides more control about where to update the count.

Fixes #40349. See #38699.

Built from https://develop.svn.wordpress.org/trunk@40485


git-svn-id: http://core.svn.wordpress.org/trunk@40361 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-04-20 00:14:43 +00:00
Felix Arntz
7fa610b34a Multisite: Add $network_id parameter to wp_update_network_site_counts().
Using the new parameter, it is now possible to update the site counts on a network different from the current network.

Props PieWP, johnjamesjacoby.
Fixes #37528. See #38699.

Built from https://develop.svn.wordpress.org/trunk@40484


git-svn-id: http://core.svn.wordpress.org/trunk@40360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-04-20 00:00:42 +00:00
Felix Arntz
ce6153d52a Multisite: Partially revert [40295].
[40295] removed the restriction of a minimum amount of characters for new site names, which could cause unexpected behavior. That changeset is reverted here with the exception of the removal of the `is_super_admin()` check, which can safely be omitted. A new filter for the minimum site name length will be introduced later to be able to modify that behavior.

See #39676, #37616.

Built from https://develop.svn.wordpress.org/trunk@40391


git-svn-id: http://core.svn.wordpress.org/trunk@40298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-04-07 13:15:42 +00:00
Felix Arntz
58b810e9eb Multisite: Add $network_id parameter to get_user_count().
The `get_user_count()` function returns the number of active users on a network, which is stored in a `user_count` network option. Since `get_network_option()` supports retrieving options from other networks than the current one, `get_user_count()` can now make use of that feature.

Fixes #37866.

Built from https://develop.svn.wordpress.org/trunk@40371


git-svn-id: http://core.svn.wordpress.org/trunk@40278 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-04-05 02:18:00 +00:00
Felix Arntz
924e31583c Multisite: Support the $network_id parameter of get_blog_count().
The `get_blog_count()` function used to support an `$id` parameter for the network ID prior to WordPress 3.1. This parameter has not been used since the introduction of `get_site_option()` and was later deprecated in [25113]. With `get_network_option()` however it is possible to support the parameter again, now properly renamed as `$network_id`.

A unit test has for the parameter has been added as well. Another unit test in the same class was adjusted to work properly with multiple networks existing.

Fixes #37865.

Built from https://develop.svn.wordpress.org/trunk@40370


git-svn-id: http://core.svn.wordpress.org/trunk@40277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-04-05 02:17:18 +00:00
Felix Arntz
2295ed8031 Multisite: Remove restriction of minimum site name length in wpmu_validate_blog_signup().
It is sometimes desirable to support shorter site names than 4 characters, therefore that restriction should be removed. It is still possible to manually enforce it by using the `wpmu_validate_blog_signup` filter.

As a result of this change, another `is_super_admin()` call gets removed which affects the ongoing efforts of working on a network-wide role system.

Props milindmore22.
Fixes #39676. See #37616.

Built from https://develop.svn.wordpress.org/trunk@40295


git-svn-id: http://core.svn.wordpress.org/trunk@40202 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-03-17 14:36:43 +00:00
Sergey Biryukov
3c1ce66767 Users: Introduce signup_site_meta and signup_user_meta for filtering signup metadata in wpmu_signup_blog() and wpmu_signup_user(), respectively.
Props Mista-Flo.
Fixes #39223.
Built from https://develop.svn.wordpress.org/trunk@39920


git-svn-id: http://core.svn.wordpress.org/trunk@39857 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-17 03:53:42 +00:00
Sergey Biryukov
351a3b6d69 Docs: Make $meta parameter description in multisite signup and registration functions more consistent.
See #38781.
Built from https://develop.svn.wordpress.org/trunk@39887


git-svn-id: http://core.svn.wordpress.org/trunk@39824 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-12 05:21:41 +00:00
Sergey Biryukov
3f59be8c97 Users: In wpmu_signup_blog() and wpmu_signup_user(), pass unserialized signup meta data to after_signup_site and after_signup_user filters introduced in [34112], to match the documented value.
Props MaximeCulea.
Fixes #38781.
Built from https://develop.svn.wordpress.org/trunk@39886


git-svn-id: http://core.svn.wordpress.org/trunk@39823 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-12 04:57:39 +00:00
Jeremy Felt
cea9e2dc62 Multisite: Use wp_rand() in signup key creation.
Built from https://develop.svn.wordpress.org/trunk@39795


git-svn-id: http://core.svn.wordpress.org/trunk@39733 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-11 05:30:42 +00:00
John Blackbourn
80a839de13 Docs: Misc corrections and additions to inline documentation.
See #39130
Props keesiemeijer

Built from https://develop.svn.wordpress.org/trunk@39639


git-svn-id: http://core.svn.wordpress.org/trunk@39579 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-27 09:28:40 +00:00
John Blackbourn
d327c92e4b Docs: Add and correct @since docs for a variety of functions and methods.
Props keesiemeijer, chris_dev
Fixes #39343, #39357, #39344
See #39130

Built from https://develop.svn.wordpress.org/trunk@39638


git-svn-id: http://core.svn.wordpress.org/trunk@39578 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-27 09:21:44 +00:00
John Blackbourn
4cf5550d8d I18n: Begin introducing translator comments for strings which include placeholders but no accompanying translator comment.
Adds context to one string used in two different contexts for the new user and new site signup email notification.

More to come.

See #38882

Built from https://develop.svn.wordpress.org/trunk@39323


git-svn-id: http://core.svn.wordpress.org/trunk@39263 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-21 01:22:32 +00:00
Dominik Schilling
788761c601 Multisite: Rename the $user parameter to $user_login in wpmu_signup_blog_notification() and wpmu_signup_user_notification().
[38961] added a `$user = get_user_by( 'login', $user );` call which was overriding the `$user` string variable for the login name. The change to `$user_login` makes this clear.

Props johnjamesjacoby.
Fixes #38763.
Built from https://develop.svn.wordpress.org/trunk@39203


git-svn-id: http://core.svn.wordpress.org/trunk@39143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-11 22:20:33 +00:00
Dominik Schilling
7819e2b4ba I18N: Introduce a locale-switching function.
With the introduction of user-specific languages in [38705] it's necessary to be able to switch translations on the fly. For example emails should be sent in the language of the recipient and not the one of the current user.

This introduces a new `WP_Locale_Switcher` class which is used for switching locales and translations. It holds the stack of locales whenever `switch_to_locale( $locale )` is called. With `restore_previous_locale()` you can restore the previous locale. `restore_current_locale()` empties the stack and sets the locale back to the initial value.

`switch_to_locale()` is added to most of core's email functions, either with the value of `get_locale()` (site language) or `get_user_locale()` (user language with fallback to site language).

Props yoavf, tfrommen, swissspidy, pbearne, ocean90.
See #29783.
Fixes #26511.
Built from https://develop.svn.wordpress.org/trunk@38961


git-svn-id: http://core.svn.wordpress.org/trunk@38904 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-26 15:36:31 +00:00