Skip to content

Fix for wrong locale code in the admin for core/get-site-info` ability#11492

Closed
sangu310 wants to merge 2 commits intoWordPress:trunkfrom
sangu310:fix/ticket-64977
Closed

Fix for wrong locale code in the admin for core/get-site-info` ability#11492
sangu310 wants to merge 2 commits intoWordPress:trunkfrom
sangu310:fix/ticket-64977

Conversation

@sangu310
Copy link
Copy Markdown

@sangu310 sangu310 commented Apr 9, 2026

The core/get-site-info ability should return the site locale, but currently returns the user locale in admin due to using get_bloginfo(), which relies on determine_locale().

This can vary based on context (admin, login, request params, JSON requests), making it unreliable for getting the actual site locale.

The site's language is stored directly as the WPLANG option. Reading it bypasses all the context-dependent filtering:

if ( 'language' === $field ) {
$result[ $field ] = str_replace( '', '-', get_option( 'WPLANG' ) ?: 'en_US' );
}
get_option('WPLANG') returns the raw DB value — no context influence
The ?: 'en_US' handles the default English case where WPLANG is an empty string
str_replace('
', '-', ...) preserves the existing BCP 47 formatting (e.g. en-US, pt-BR)

Multisite Behavior
In multisite, get_option() already scopes to the current site (it internally routes through get_blog_option()), so no special handling is needed. Each site in the network correctly returns its own configured language. If you ever needed the network-level language, that would be get_network_option(null, 'WPLANG'), but that's not appropriate for core/get-site-info.

@sangu310 sangu310 closed this Apr 9, 2026
@sangu310 sangu310 deleted the fix/ticket-64977 branch April 9, 2026 05:49
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Hi @sangu310! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant