user_login;
} else {
// For user-edit.php, we need to get the user ID from the URL.
$user_id = isset( $_GET['user_id'] ) ? absint( $_GET['user_id'] ) : $current_user->ID;
// Verify the current user can edit this specific user for security.
if ( ! current_user_can( 'edit_user', $user_id ) ) {
$user_id = $current_user->ID;
}
$user_info = get_userdata( $user_id );
$original_username = $user_info ? $user_info->user_login : '';
}
// Prepare texts
$text_activated = esc_js( __( 'Username editing is now activated. You can change the username above.', 'allow-username-edit' ) );
$text_protected = esc_js( __( 'Username is protected. Check the box to enable editing.', 'allow-username-edit' ) );
$text_confirm = esc_js( __( 'Are you sure you want to change the username? This action may require the user to log in again.', 'allow-username-edit' ) );
$text_email_warning = esc_js( __( 'Warning: Use of email addresses in usernames is discouraged for security reasons.', 'allow-username-edit' ) );
// Add translation labels for all translatable texts to translation template
/* translators: Message shown when username editing is activated. */
__( 'Username editing is now activated. You can change the username above.', 'allow-username-edit' );
/* translators: Message shown when username editing is protected. */
__( 'Username is protected. Check the box to enable editing.', 'allow-username-edit' );
/* translators: Confirmation message shown before username change. */
__( 'Are you sure you want to change the username? This action may require the user to log in again.', 'allow-username-edit' );
/* translators: Warning message shown when username contains @ symbol. */
__( 'Warning: Use of email addresses in usernames is discouraged for security reasons.', 'allow-username-edit' );
/* translators: Error message when username contains @ symbol. */
__( 'Usernames cannot contain "@" symbol or resemble email addresses.', 'allow-username-edit' );
/* translators: Label for the username editing section. */
__( 'Edit Username', 'allow-username-edit' );
/* translators: Label for the activate checkbox. */
__( 'Activate username editing', 'allow-username-edit' );
/* translators: Error message when username is invalid. */
__( 'This username is invalid.', 'allow-username-edit' );
/* translators: Error message when username already exists. */
__( 'This username is already registered.', 'allow-username-edit' );
/* translators: Error message when checkbox is not checked. */
__( 'You must activate username editing by checking the checkbox above before making changes.', 'allow-username-edit' );
/* translators: Page title for settings page. */
__( 'Username Edit Settings', 'allow-username-edit' );
/* translators: Section heading for plugin information. */
__( 'Plugin Information', 'allow-username-edit' );
/* translators: Label for plugin name. */
__( 'Plugin Name:', 'allow-username-edit' );
/* translators: Plugin name. */
__( 'Allow Username Edit', 'allow-username-edit' );
/* translators: Label for version. */
__( 'Version:', 'allow-username-edit' );
/* translators: Label for description. */
__( 'Description:', 'allow-username-edit' );
/* translators: Plugin description. */
__( 'This plugin allows administrators to safely edit usernames of registered users with built-in protection against accidental changes.', 'allow-username-edit' );
/* translators: Label for author. */
__( 'Author:', 'allow-username-edit' );
/* translators: Label for author URI. */
__( 'Author URI:', 'allow-username-edit' );
/* translators: Section heading for usage instructions. */
__( 'Usage Instructions', 'allow-username-edit' );
/* translators: Step 1 of usage instructions. */
__( 'Navigate to Users → All Users', 'allow-username-edit' );
/* translators: Step 2 of usage instructions. */
__( 'Click "Edit" on any user', 'allow-username-edit' );
/* translators: Step 3 of usage instructions. */
__( 'Check the "Activate username editing" checkbox above the username field', 'allow-username-edit' );
/* translators: Step 4 of usage instructions. */
__( 'Edit the username as needed', 'allow-username-edit' );
/* translators: Step 5 of usage instructions. */
__( 'Confirm the change when prompted', 'allow-username-edit' );
/* translators: Section heading for support. */
__( 'Support the Plugin', 'allow-username-edit' );
/* translators: Text encouraging donation. */
__( 'If you find this plugin useful, please consider making a donation to support continued development and maintenance.', 'allow-username-edit' );
/* translators: Button text for donation. */
__( 'Donate via PayPal', 'allow-username-edit' );
$label_th = esc_html__( 'Edit Username', 'allow-username-edit' );
$label_cb = esc_html__( 'Activate username editing', 'allow-username-edit' );
$checkbox_row_html = '