Skip to content

Fix/untranslatable login register string#1901

Open
dev-alamin wants to merge 2 commits into
weDevsOfficial:developfrom
dev-alamin:fix/untranslatable-login-register-string
Open

Fix/untranslatable login register string#1901
dev-alamin wants to merge 2 commits into
weDevsOfficial:developfrom
dev-alamin:fix/untranslatable-login-register-string

Conversation

@dev-alamin

@dev-alamin dev-alamin commented Jul 3, 2026

Copy link
Copy Markdown

Fix – "Don't have an account?" not translatable via Loco Translate / .po tools

Partially addresses #1797

Problem

Simple_Login::get_action_links() builds two similar auth links. The "login" link
correctly wraps its entire phrase in __():

sprintf(
    __( 'Already have an account? <a href="%1$s">%2$s</a>', 'wp-user-frontend' ),
    esc_url( $this->get_action_url( 'login' ) ),
    esc_html( __( 'Login', 'wp-user-frontend' ) )
);

The "register" link does not follow the same pattern — "Don't have an account? " is
a raw PHP string embedded directly in the sprintf() template, never passed through
__()/_e():

$links[] = sprintf( '%sDon\'t have an account? %s<a href="%s">%s</a>', '<span class="wpuf-register-text">', '</span>', $this->get_action_url( 'register' ), __( 'Register', 'wp-user-frontend' ) );

Translation tools (Loco Translate, Poedit, wp i18n make-pot) build their string
lists by scanning source for gettext function calls. A string outside one of those
calls is invisible to them regardless of .po/.mo state — which matches the
report and what I found checking the shipped languages/*.po files (the phrase
isn't in any of them).

Fix

Wrap the full phrase in __(), following the same pattern already used for the
login link two branches above it, and add esc_url()/esc_html() on the dynamic
parts for consistency with that same sibling code:

$links[] =
        sprintf(
            /* translators: %1$s: opening span tag, %2$s: closing span tag, %3$s: register URL, %4$s: register text */
            __( '%1$sDon\'t have an account?%2$s <a href="%3$s">%4$s</a>', 'wp-user-frontend' ),
            '<span class="wpuf-register-text">',
            '</span>',
            esc_url( $this->get_action_url( 'register' ) ),
            esc_html( __( 'Register', 'wp-user-frontend' ) )
        );

Only whitespace placement changed cosmetically (the space between the question and
the closing </span> now sits outside the span instead of inside it) — no visible
or functional change to markup structure or styling.

Scope note for reviewers

The report lists two untranslatable strings: "Enter" and "Don't have an account?".
This PR only fixes the latter. I searched the entire free plugin (PHP templates,
widgets, and all built JS bundles) for a user-facing "Enter" string anywhere in the
login flow and couldn't find one — the only occurrence of "Enter" in the codebase is
a keyboard-event key comparison in the User Directory admin screen, unrelated to
login. My best guess is that string belongs to WP User Frontend Pro's code, which
isn't in this repository, so I can't verify or fix it here. Flagging this so it
doesn't get lost — happy to take a look if someone can confirm where "Enter" is
rendered.

Testing

  • Confirmed the fixed string is now discoverable by grepping for __( calls (what
    Loco Translate's parser and wp i18n make-pot rely on).
  • Verified the login link Already have an account? ... continues to render
    unchanged — no behavior change to sibling code.
  • 1-line-of-behavior diff (wrapping + escaping only); no change to the rendered
    HTML structure.

Summary by CodeRabbit

  • Bug Fixes
    • Improved the registration prompt so the “Register” link is fully translatable and displays correctly in more languages.
    • Added extra safety when processing submitted field values, helping avoid issues when a field isn’t available.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9cc2363b-e6ac-4eae-a667-029c3a4cf040

📥 Commits

Reviewing files that changed from the base of the PR and between e7c6e79 and 815ad0e.

📒 Files selected for processing (2)
  • includes/Free/Simple_Login.php
  • includes/Traits/FieldableTrait.php

Walkthrough

Modifies the registration link markup in Simple_Login to use a translatable sprintf template, and adds an existence check for $wpuf_field before invoking sanitize_field_data in FieldableTrait's prepare_meta_fields method.

Changes

Login link and field sanitization fixes

Layer / File(s) Summary
Translatable registration link markup
includes/Free/Simple_Login.php
Register link rendering now uses a translatable sprintf() template with placeholders for wrapping <span> tags and the register URL/text, replacing the prior concatenated string.
Guard sanitize_field_data call
includes/Traits/FieldableTrait.php
Adds a truthy check on $wpuf_field before calling sanitize_field_data(), preventing execution when the field instance is unavailable.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested labels: bug

Poem

A span, a sprintf, a tidy little fix,
No more raw strings in the markup mix.
A field checked twice before it's sanitized,
This bunny hops on, code fortified. 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: making the login register string translatable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant