WP_Locale_Switcher::restore_previous_locale()publicWP 4.7.0

Restores the translations according to the previous locale.

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

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

Возвращает

Строку|false. Locale on success, false on failure.

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

$WP_Locale_Switcher = new WP_Locale_Switcher();
$WP_Locale_Switcher->restore_previous_locale();

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

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

Код WP_Locale_Switcher::restore_previous_locale() WP 6.4.3

public function restore_previous_locale() {
	$previous_locale = array_pop( $this->stack );

	if ( null === $previous_locale ) {
		// The stack is empty, bail.
		return false;
	}

	$entry  = end( $this->stack );
	$locale = is_array( $entry ) ? $entry[0] : false;

	if ( ! $locale ) {
		// There's nothing left in the stack: go back to the original locale.
		$locale = $this->original_locale;
	}

	$this->change_locale( $locale );

	/**
	 * Fires when the locale is restored to the previous one.
	 *
	 * @since 4.7.0
	 *
	 * @param string $locale          The new locale.
	 * @param string $previous_locale The previous locale.
	 */
	do_action( 'restore_previous_locale', $locale, $previous_locale[0] );

	return $locale;
}