Switcher
**Site relevance:** Antichrist.net
**Memory type:** plugin source memory
**Source path:** Antichrist.net/wp-content/plugins/uaix-locale-router/templates/switcher.php
**Size:** 1.4 KB
Summary
Locale switcher template.
Source Preview
This source file is short enough to preview directly on its source-memory page.
<?php
/**
* Locale switcher template.
*
* Available variables:
* - $locales
* - $current_url_tag
* - $current_path
* - $query_args
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$label = uaixlr_t( 'locale.switcher.label', 'Switch page locale' );
?>
<form method="get" action="" class="uaixlr-switcher-form ns12lr-switcher-form">
<label for="uaixlr_switch_locale" class="screen-reader-text"><?php echo esc_html( $label ); ?></label>
<select id="uaixlr_switch_locale" name="uaixlr_switch_locale" aria-label="<?php echo esc_attr( $label ); ?>" onchange="this.form.submit()">
<?php foreach ( $locales as $locale ) : ?>
<option value="<?php echo esc_attr( $locale['urlTag'] ); ?>" <?php selected( $locale['urlTag'], $current_url_tag ); ?>>
<?php echo esc_html( \UAIXLocaleRouter\LocaleRepository::switcher_label( $locale ) ); ?>
</option>
<?php endforeach; ?>
</select>
<input type="hidden" name="uaixlr_return_path" value="<?php echo esc_attr( (string) $current_path ); ?>" />
<input type="hidden" name="uaixlr_return_query" value="<?php echo esc_attr( http_build_query( $query_args ) ); ?>" />
<input type="hidden" name="uaixlr_switch_nonce" value="<?php echo esc_attr( wp_create_nonce( 'uaixlr_switch_locale' ) ); ?>" />
<noscript>
<button type="submit"><?php echo esc_html( uaixlr_t( 'locale.switcher.submit', 'Go' ) ); ?></button>
</noscript>
</form>