Make WordPress Core


Ignore:
Timestamp:
10/21/2018 03:02:49 PM (6 years ago)
Author:
danielbachhuber
Message:

REST API: Render response in user locale with ?_locale=user.

Introduces new determine_locale() function for deciding the proper locale to use for a response. Default value is get_user_locale() in the admin, and get_locale() on the frontend. Because REST API requests are considered frontend requests, ?_locale=user can be used to render the response in the user's locale.

Also updates wp-login.php?wp_lang implementation to benefit from this abstraction.

Props flixos90, mnelson4, swissspidy, TimothyBlynJacobs.
Fixes #44758.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/general-template.php

    r43761 r43776  
    704704            $output = __( 'html_lang_attribute' );
    705705            if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) {
    706                 $output = is_admin() ? get_user_locale() : get_locale();
     706                $output = determine_locale();
    707707                $output = str_replace( '_', '-', $output );
    708708            }
Note: See TracChangeset for help on using the changeset viewer.