From c85dcfaaf1cc3abaca585d8b48700f00a9a9956d Mon Sep 17 00:00:00 2001 From: James Griffin Date: Tue, 28 Jul 2026 22:58:24 -0300 Subject: [PATCH] Name the destination page in the continue link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Continue to your account" says nothing about where the link goes. Use the chosen page's own title instead — "Continue to Book a Lesson" — so the visitor knows before clicking. An untitled page keeps the generic wording rather than rendering "Continue to ". --- docs/features/account-registration.md | 2 +- src/Auth/RegistrationPage.php | 30 +++++++++++++++++------- tests/Unit/Auth/RegistrationPageTest.php | 19 +++++++++++++++ 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/docs/features/account-registration.md b/docs/features/account-registration.md index 2baea72..96edd27 100644 --- a/docs/features/account-registration.md +++ b/docs/features/account-registration.md @@ -132,7 +132,7 @@ recorded in `us_policy_acceptances` with `registration_type = account` and The block's **After registration** panel picks the page a student continues to once registration finishes, and whether they get there by hand or automatically. -- **Sign-in page** (`loginPageId` / `login_page_id`) — the target of the "Sign in to your account" link shown after email confirmation (`?us_confirmed=1|ready`, falling back to the WordPress login screen) and of the "Continue to your account" link every **logged-in** visitor gets (`RegistrationPage::continueLink()`): an invited student who just finished signing up (`?us_registered=invite`), and anyone who simply arrives at the registration page already signed in. Neither gets the WordPress-login-screen fallback — with no page chosen there is no link at all, since sending someone already signed in to the login screen is the same dead end with extra steps. +- **Sign-in page** (`loginPageId` / `login_page_id`) — the target of the "Sign in to your account" link shown after email confirmation (`?us_confirmed=1|ready`, falling back to the WordPress login screen) and of the **"Continue to _<page title>_"** link every **logged-in** visitor gets (`RegistrationPage::continueLink()`): an invited student who just finished signing up (`?us_registered=invite`), and anyone who simply arrives at the registration page already signed in. The link names the chosen page (via `get_the_title()`) so the visitor knows where it goes; an untitled page falls back to "Continue to your account" rather than reading "Continue to ". Neither gets the WordPress-login-screen fallback — with no page chosen there is no link at all, since sending someone already signed in to the login screen is the same dead end with extra steps. - **Redirect automatically** (`autoRedirect`, block only) — sends the student to that page instead of showing the link, via `BlockRegistrar::maybeAutoRedirect()` on `template_redirect`. It fires only on those two finished states (`RegistrationPage::isRegistrationComplete()`), so the "check your email" step, a validation error, and an `expired` confirmation link are always shown rather than redirected past. With no page chosen nothing happens — there is deliberately no login-screen fallback for the redirect. See `editor-blocks.md`. ## Token Redirect diff --git a/src/Auth/RegistrationPage.php b/src/Auth/RegistrationPage.php index 5e0db1a..87c0278 100644 --- a/src/Auth/RegistrationPage.php +++ b/src/Auth/RegistrationPage.php @@ -351,8 +351,10 @@ class RegistrationPage { } /** - * The "continue to your account" paragraph shown to a logged-in visitor, or - * an empty string when no destination page is configured. + * The "continue" paragraph shown to a logged-in visitor, or an empty string + * when no destination page is configured. The link names the chosen page, so + * the visitor knows where it goes before clicking; an untitled page falls + * back to generic wording rather than reading "Continue to ". * * The sign-in-page fallback {@see loginUrl()} applies is deliberately not * used here: pointing someone who is already signed in at the login screen is @@ -361,13 +363,25 @@ class RegistrationPage { * @param array $atts */ private function continueLink( array $atts ): string { - $continue = $this->continueUrl( $this->successPageId( $atts ) ); + $pageId = $this->successPageId( $atts ); + $continue = $this->continueUrl( $pageId ); - return null === $continue - ? '' - : '

' - . esc_html__( 'Continue to your account', 'unsupervised-schedular' ) - . '

'; + if ( null === $continue ) { + return ''; + } + + $title = trim( Val::string( get_the_title( $pageId ) ) ); + $label = '' === $title + ? esc_html__( 'Continue to your account', 'unsupervised-schedular' ) + : esc_html( + sprintf( + /* translators: %s: title of the page the student continues to. */ + __( 'Continue to %s', 'unsupervised-schedular' ), + $title + ) + ); + + return '

' . $label . '

'; } /** diff --git a/tests/Unit/Auth/RegistrationPageTest.php b/tests/Unit/Auth/RegistrationPageTest.php index ff0f88a..68e84ff 100644 --- a/tests/Unit/Auth/RegistrationPageTest.php +++ b/tests/Unit/Auth/RegistrationPageTest.php @@ -497,11 +497,28 @@ class RegistrationPageTest extends TestCase Functions\when('is_user_logged_in')->justReturn(true); Functions\when('sanitize_key')->alias(static fn ($v) => strtolower((string) $v)); Functions\expect('get_permalink')->once()->with(4)->andReturn('http://home.test/welcome/'); + Functions\when('get_the_title')->justReturn('Book a Lesson'); $html = $this->ctx['page']->render([ 'loginPageId' => 4 ]); self::assertStringContainsString('now logged in', $html); self::assertStringContainsString('href="http://home.test/welcome/"', $html); + // The link names its destination rather than saying "your account". + self::assertStringContainsString('Continue to Book a Lesson', $html); + } + + public function testContinueLinkFallsBackToGenericWordingForAnUntitledPage(): void + { + Functions\when('is_user_logged_in')->justReturn(true); + Functions\when('sanitize_key')->alias(static fn ($v) => strtolower((string) $v)); + Functions\when('get_permalink')->justReturn('http://home.test/welcome/'); + Functions\when('get_the_title')->justReturn(' '); + + // An untitled page must not produce a link reading "Continue to ". + $html = $this->ctx['page']->render([ 'loginPageId' => 4 ]); + + self::assertStringContainsString('Continue to your account', $html); + self::assertStringContainsString('href="http://home.test/welcome/"', $html); } public function testAlreadyLoggedInVisitorIsLinkedToTheChosenPage(): void @@ -511,11 +528,13 @@ class RegistrationPageTest extends TestCase Functions\when('is_user_logged_in')->justReturn(true); Functions\when('sanitize_key')->alias(static fn ($v) => strtolower((string) $v)); Functions\expect('get_permalink')->once()->with(4)->andReturn('http://home.test/welcome/'); + Functions\when('get_the_title')->justReturn('Book a Lesson'); $html = $this->ctx['page']->render([ 'loginPageId' => 4 ]); self::assertStringContainsString('already have an account', $html); self::assertStringContainsString('href="http://home.test/welcome/"', $html); + self::assertStringContainsString('Continue to Book a Lesson', $html); // Not the just-registered message — that branch needs its own flag. self::assertStringNotContainsString('us-success', $html); }