Settingspage - Source Excerpt 01
Summary
This source excerpt preserves a bounded section of Antichrist.net/wp-content/plugins/uaix-locale-router/src/Admin/SettingsPage.php so readers can inspect the evidence without opening the full source file.
**Source path:** Antichrist.net/wp-content/plugins/uaix-locale-router/src/Admin/SettingsPage.php
<?php
namespace UAIXLocaleRouter\Admin;
use UAIXLocaleRouter\LocaleRepository;
use UAIXLocaleRouter\LocaleValidator;
use UAIXLocaleRouter\Plugin;
use UAIXLocaleRouter\Support\Html;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
final class SettingsPage {
/**
* Render the settings page.
*
* @return void
*/
public static function render_settings_page() {
$settings = Plugin::settings();
$supported_locales = LocaleRepository::get_supported_locales();
?>
<div class="wrap">
<h1>UAIX Locale Router Settings</h1>
<div class="uaixlr-callout uaixlr-callout-info">
<p><strong>Before go-live:</strong> open the <a href="<?php echo esc_url( AdminPages::page_url( 'uaixlr-status' ) ); ?>">Status page</a> or <a href="<?php echo esc_url( admin_url( 'site-health.php' ) ); ?>">Site Health</a> and confirm the localized homepage URL loads successfully.</p>
<p class="description">If the check reports an HTTP 404 for <code>/<?php echo esc_html( LocaleRepository::get_default_url_tag() ); ?>/</code>, the plugin is installed but the web server still is not forwarding locale-prefixed pretty URLs into WordPress. The plugin can repair the site-root <code>.htaccess</code> file automatically only when WordPress has permission to write it. On Apache or LiteSpeed, open the Status page and use <strong>Repair .htaccess</strong> when it is available. If automatic repair is not available, the Status page shows the exact rewrite snippet to paste into the site-root <code>.htaccess</code> file beside <code>wp-admin</code>, <code>wp-content</code>, and <code>index.php</code>.</p>
<p class="description">For internal navigation, do not hardcode bare links such as <code>/spec/</code> or specific-language links such as <code>/en-us/spec/</code> unless they are an intentional language switcher. Use WordPress-generated links so the active locale stays intact.</p>
</div>
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" class="uaixlr-admin-form">
<?php wp_nonce_field( 'uaixlr_save_settings' ); ?>
<input type="hidden" name="action" value="uaixlr_save_settings" />
<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row"><label for="uaixlr_enabled">Enable plugin</label></th>
<td><input type="checkbox" id="uaixlr_enabled" name="settings[enabled]" value="1" <?php checked( ! empty( $settings['enabled'] ) ); ?> /></td>
</tr>
<tr>
<th scope="row"><label for="uaixlr_default_locale">Default locale</label></th>
<td>
<select id="uaixlr_default_locale" name="settings[default_locale]">
<?php foreach ( $supported_locales as $locale ) : ?>
<option value="<?php echo esc_attr( $locale['tag'] ); ?>" <?php selected( $settings['default_locale'], $locale['tag'] ); ?>>
<?php echo esc_html( $locale['nativeName'] . ' (' . $locale['tag'] . ')' ); ?>
</option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="uaixlr_redirect_bare_urls">Redirect bare URLs</label></th>
<td>
<input type="checkbox" id="uaixlr_redirect_bare_urls" name="settings[redirect_bare_urls]" value="1" <?php checked( ! empty( $settings['redirect_bare_urls'] ) ); ?> />
<p class="description">Public URLs without a locale prefix redirect to the best enabled browser-language match, or fall back to the configured default locale.</p>
</td>
</tr>
<tr>
<th scope="row"><label for="uaixlr_redirect_status_code">Redirect status code</label></th>
<td>
<select id="uaixlr_redirect_status_code" name="settings[redirect_status_code]">
<option value="301" <?php selected( (int) $settings['redirect_status_code'], 301 ); ?>>301 Permanent</option>
<option value="302" <?php selected( (int) $settings['redirect_status_code'], 302 ); ?>>302 Temporary</option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="uaixlr_trailing_slash_strategy">Trailing slash strategy</label></th>
<td>
<select id="uaixlr_trailing_slash_strategy" name="settings[trailing_slash_strategy]">
<option value="always" <?php selected( $settings['trailing_slash_strategy'], 'always' ); ?>>Always</option>
<option value="never" <?php selected( $settings['trailing_slash_strategy'], 'never' ); ?>>Never</option>
<option value="preserve" <?php selected( $settings['trailing_slash_strategy'], 'preserve' ); ?>>Preserve input</option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="uaixlr_rest_localization_mode">REST localization mode</label></th>
<td>
<select id="uaixlr_rest_localization_mode" name="settings[rest_localization_mode]">
<option value="unlocalized" <?php selected( $settings['rest_localization_mode'], 'unlocalized' ); ?>>Keep REST unlocalized</option>
<option value="prefixed" <?php selected( $settings['rest_localization_mode'], 'prefixed' ); ?>>Allow prefixed REST routes</option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="uaixlr_content_link_rewriting">Rewrite content links</label></th>
<td><input type="checkbox" id="uaixlr_content_link_rewriting" name="settings[content_link_rewriting]" value="1" <?php checked( ! empty( $settings['content_link_rewriting'] ) ); ?> /></td>
</tr>
<tr>
<th scope="row"><label for="uaixlr_enqueue_front_assets">Load switcher assets</label></th>
<td>
<input type="checkbox" id="uaixlr_enqueue_front_assets" name="settings[enqueue_front_assets]" value="1" <?php checked( ! empty( $settings['enqueue_front_assets'] ) ); ?> />
<p class="description">Disable only if your theme provides its own switcher styles.</p>
</td>
</tr>
<tr>
<th scope="row"><label for="uaixlr_debug_banner_enabled">Debug banner</label></th>
<td>
<input type="checkbox" id="uaixlr_debug_banner_enabled" name="settings[debug_banner_enabled]" value="1" <?php checked( ! empty( $settings['debug_banner_enabled'] ) ); ?> />
<p class="description">Show front-end diagnostics only to administrators in local, staging, or WP_DEBUG environments.</p>
</td>
</tr>
<tr>
<th scope="row"><label for="uaixlr_cleanup_legacy_ns12">Legacy NS12 cleanup on uninstall</label></th>
<td>
<input type="checkbox" id="uaixlr_cleanup_legacy_ns12" name="settings[cleanup_legacy_ns12]" value="1" <?php checked( ! empty( $settings['cleanup_legacy_ns12'] ) ); ?> />
<p class="description">Leave disabled for rollback safety. When enabled, uninstall also removes old NS12 options, dictionary uploads, and validation history.</p>
</td>
</tr>
<tr>
<th scope="row"><label for="uaixlr_exclusion_patterns">Exclusion patterns</label></th>
<td>
<textarea id="uaixlr_exclusion_patterns" name="settings[exclusion_patterns]" rows="5" class="large-text code"><?php echo esc_textarea( $settings['exclusion_patterns'] ); ?></textarea>
<p class="description">One path fragment per line. Matching requests and links stay unlocalized.</p>
</td>
</tr>
</tbody>
</table>
<?php submit_button( 'Save Settings' ); ?>
</form>
</div>
<?php
}
/**
* Render the locale catalog page.
*
* @return void
*/
public static function render_locales_page() {
$search = isset( $_GET['locale_search'] ) ? sanitize_text_field( wp_unslash( $_GET['locale_search'] ) ) : '';
$supported_locales = LocaleRepository::get_supported_locales();
$catalog_results = LocaleRepository::search_catalog( $search, 25 );
$default_locale = Plugin::settings()['default_locale'];
?>
<div class="wrap">
<h1>Locale Catalog</h1>
<div class="uaixlr-grid">
<div class="uaixlr-card">
<h2>Add Locale</h2>
<form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
<?php wp_nonce_field( 'uaixlr_add_locale' ); ?>
<input type="hidden" name="action" value="uaixlr_add_locale" />
<p>
<label for="uaixlr_new_locale_tag">Locale tag</label><br />
<input type="text" id="uaixlr_new_locale_tag" name="new_locale_tag" class="regular-text" placeholder="en-US" />
</p>
<?php submit_button( 'Add Locale', 'secondary', 'submit', false ); ?>
</form>
<form method="get" action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>" class="uaixlr-search-form">
<input type="hidden" name="page" value="uaixlr-locales" />
<p>
<label for="uaixlr_locale_search">Search shipped locale catalog</label><br />