Skip to content

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

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

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

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-abilities branch April 9, 2026 06:40
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