WP_Locale_Switcher::change_locale()privateWP 4.7.0

Changes the site's locale to the given one.

Loads the translations, changes the global $wp_locale object and updates all post type labels.

Метод класса: WP_Locale_Switcher{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->change_locale( $locale );
$locale(строка) (обязательный)
The locale to change to.

Заметки

  • Global. WP_Locale. $wp_locale WordPress date and time locale object.

Список изменений

С версии 4.7.0 Введена.

Код WP_Locale_Switcher::change_locale() WP 6.5.2

private function change_locale( $locale ) {
	global $wp_locale;

	$this->load_translations( $locale );

	$wp_locale = new WP_Locale();

	WP_Translation_Controller::get_instance()->set_locale( $locale );

	/**
	 * Fires when the locale is switched to or restored.
	 *
	 * @since 4.7.0
	 *
	 * @param string $locale The new locale.
	 */
	do_action( 'change_locale', $locale );
}