get_locale(): string
- Since
- 1.5.0
- Source
wp-includes/l10n.php:30
Retrieves the current locale.
Description
If the locale is set, then it will filter the locale in the 'locale' filter hook and return the value. If the locale is not set already, then the WPLANG constant is used if it is defined. Then it is filtered through the 'locale' filter hook and the value for the locale global set and the locale is returned. The process to get the locale should only be done once, but the locale will always be filtered using the 'locale' hook.
Return
string- The locale of the blog or from the 'locale' hook.
Hooks fired · 2
2 hooks fire while get_locale() runs, in this order:
- apply_filters( locale )filterline 35 (+5 into the body)
Filters the locale ID of the WordPress installation.
- apply_filters( locale )filterline 80 (+50 into the body)
Filters the locale ID of the WordPress installation.
Uses · 5
- apply_filters()Calls the callback functions that have been added to a filter hook.
- is_multisite()Determines whether Multisite is enabled.
- wp_installing()Checks or sets whether WordPress is in "installation" mode.
- get_site_option()Retrieve an option value for the current network based on name of option.
- get_option()Retrieves an option value based on an option name.
Used by · 26
- WP_Automatic_Updater::send_debug_email()Prepares and sends an email of a full log of background update results, useful for debugging and geekery.
- WP_Automatic_Updater::send_email()Sends an email upon the completion or failure of a background core update.
- WP_Automatic_Updater::send_plugin_theme_email()Sends an email upon the completion or failure of a plugin or theme background update.
- WP_Debug_Data::get_wp_core()Gets the WordPress core section of the debug data.
- WP_Recovery_Mode_Email_Service::send_recovery_mode_email()Sends the Recovery Mode email to the site admin email address.
- _wp_privacy_send_erasure_fulfillment_notification()Notifies the user when their erasure request is fulfilled.
- determine_locale()Determines the current locale desired for the request.
- get_locale_stylesheet_uri()Retrieves the localized stylesheet URI.
- get_user_locale()Retrieves the locale of a user.
- insert_with_markers()Inserts an array of strings into a file (.htaccess), placing it between BEGIN and END markers.
- list_core_update()Lists available core updates.
- list_translation_updates()Display the update translations form.
Show all 26
- login_header()Outputs the login page header.
- populate_network_meta()Creates WordPress network meta and sets the default values.
- remove_accents()Converts all accent characters to ASCII characters.
- translations_api()Retrieve translations from WordPress Translation API.
- wp_maybe_decline_date()Determines if the date should be declined.
- wp_new_user_notification()Emails login credentials to a newly-registered user.
- wp_notify_moderator()Notifies the moderator of the site about a new comment that is awaiting approval.
- wp_notify_postauthor()Notifies an author (and/or others) of a comment/trackback/pingback on a post.
- wp_password_change_notification()Notifies the blog admin of a user changing password, normally via email.
- wp_privacy_send_personal_data_export_email()Send an email to the user with a link to the personal data export file
- wp_send_user_request()Send a confirmation request email to confirm an action.
- wp_timezone_choice()Gives a nicely-formatted list of timezone strings.
- wp_version_check()Checks WordPress version against the newest version.
- wpmu_new_site_admin_notification()Notifies the Multisite network administrator that a new site was created.
Source
function get_locale() { global $locale, $wp_local_package; if ( isset( $locale ) ) { /** This filter is documented in wp-includes/l10n.php */ return apply_filters( 'locale', $locale ); } if ( isset( $wp_local_package ) ) { $locale = $wp_local_package; } // WPLANG was defined in wp-config. if ( defined( 'WPLANG' ) ) { $locale = WPLANG; } // If multisite, check options. if ( is_multisite() ) { // Don't check blog option when installing. if ( wp_installing() ) { $ms_locale = get_site_option( 'WPLANG' ); } else { $ms_locale = get_option( 'WPLANG' ); if ( false === $ms_locale ) { $ms_locale = get_site_option( 'WPLANG' ); } } if ( false !== $ms_locale ) { $locale = $ms_locale; } } else { $db_locale = get_option( 'WPLANG' ); if ( false !== $db_locale ) { $locale = $db_locale; } } if ( empty( $locale ) ) { $locale = 'en_US'; } /** * Filters the locale ID of the WordPress installation. * * @since 1.5.0 * * @param string $locale The locale ID. */ return apply_filters( 'locale', $locale );}History
Introduced in 1.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-includes/l10n.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.