wppaste
WordPress

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:

  1. apply_filters( locale )filterline 35 (+5 into the body)

    Filters the locale ID of the WordPress installation.

  2. apply_filters( locale )filterline 80 (+50 into the body)

    Filters the locale ID of the WordPress installation.

Uses · 5

Used by · 23

Show all 23

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 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.