Make WordPress Core


Ignore:
Timestamp:
12/01/2020 06:05:52 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Site Health, App Passwords: Ensure REST API responses are properly translated.

The REST API requests in Site Health and App Passwords now include _locale=user in the request URL to ensure the user's locale is used instead of the site locale. Additionally, the apiRequest library now sends a JSON Accept header which is required by determine_locale() to respect the _locale query parameter.

The Site Health REST API controllers now manually load the default admin textdomain if not is_admin(). This allows for the Site Health tests to be translated even though the translations are part of the administration project and the REST API is not.

Props oglekler, kebbet, Clorith, TimothyBlynJacobs, ocean90, SergeyBiryukov, adamsilverstein.
Reviewed by TimothyBlynJacobs, SergeyBiryukov.
Merges [49716] to the 5.6 branch.
Fixes #51871.

Location:
branches/5.6
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

  • branches/5.6/src/js/_enqueues/admin/application-passwords.js

    r49549 r49724  
    4848
    4949        wp.apiRequest( {
    50             path: '/wp/v2/users/' + userId + '/application-passwords',
     50            path: '/wp/v2/users/' + userId + '/application-passwords?_locale=user',
    5151            method: 'POST',
    5252            data: request
     
    9595
    9696        wp.apiRequest( {
    97             path: '/wp/v2/users/' + userId + '/application-passwords/' + uuid,
     97            path: '/wp/v2/users/' + userId + '/application-passwords/' + uuid + '?_locale=user',
    9898            method: 'DELETE'
    9999        } ).always( function() {
     
    124124
    125125        wp.apiRequest( {
    126             path: '/wp/v2/users/' + userId + '/application-passwords',
     126            path: '/wp/v2/users/' + userId + '/application-passwords?_locale=user',
    127127            method: 'DELETE'
    128128        } ).always( function() {
Note: See TracChangeset for help on using the changeset viewer.