Skip to content

Use site host in backup codes download title - #964

Open
faithcoder wants to merge 1 commit into
WordPress:masterfrom
faithcoder:fix/957-backup-codes-identify-site-by-host
Open

Use site host in backup codes download title#964
faithcoder wants to merge 1 commit into
WordPress:masterfrom
faithcoder:fix/957-backup-codes-identify-site-by-host

Conversation

@faithcoder

Copy link
Copy Markdown

What?

Use the site's host instead of its full URL in the heading of downloaded backup-code files, and make the heading filterable.

Fixes #957

Why?

The current heading includes the scheme and path from home_url( '/' ), which makes the recovery-code file contain a directly usable target URL. The host alone still identifies the site while matching the existing translator comment and avoiding unnecessary URL details.

How?

  • Parse the host from home_url() with wp_parse_url().
  • Add the two_factor_backup_codes_download_title filter, including the generated title and user as arguments.
  • Add REST API regression coverage confirming that the download contains the host but not the full home URL and that the title can be filtered.

Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5
Used for: Investigating the issue, implementing the change, adding tests, and running validation. The resulting diff was reviewed before submission.

Testing Instructions

  1. Generate backup codes for a user through the REST API or user profile.
  2. Download the recovery-code file.
  3. Confirm its heading contains only the site's host, without the URL scheme or path.
  4. Add a callback to two_factor_backup_codes_download_title, generate codes again, and confirm the custom heading appears.

Validation performed:

  • PHP syntax checks passed for both changed files.
  • PHPCS passed for both changed files.
  • PHPStan passed for the changed provider.
  • git diff --check passed.
  • The full PHPUnit suite was not run because the required Docker environment was unavailable.

Changelog Entry

Fixed - Use the site host instead of the full URL in backup-code download headings and allow the heading to be filtered.

@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: faithcoder <faithcoder@git.wordpress.org>
Co-authored-by: dknauss <dpknauss@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

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.

Backup codes download file identifies the site by full URL rather than name or host

1 participant