Skip to content

fix[faustwp]: (#1872) use home_url() in handle_generate_endpoint#2339

Open
latenighthackathon wants to merge 1 commit intowpengine:canaryfrom
latenighthackathon:fix/faustwp-search-pattern-home-url
Open

fix[faustwp]: (#1872) use home_url() in handle_generate_endpoint#2339
latenighthackathon wants to merge 1 commit intowpengine:canaryfrom
latenighthackathon:fix/faustwp-search-pattern-home-url

Conversation

@latenighthackathon
Copy link
Copy Markdown
Contributor

Summary

On Bedrock-style installs where WordPress core lives under /wp/, site_url('/generate') returns https://example.com/wp/generate but $_SERVER['REQUEST_URI'] is still /generate. The preg_match in handle_generate_endpoint() never fires and the auth-code redirect silently breaks.

home_url() returns the public-facing URL (what REQUEST_URI actually contains), which matches on both standard and Bedrock installs.

Related Issue

Closes #1872

Refiled per @josephfusco's guidance on #2315 — a new filter is not needed, just the correct URL helper.

Confirm the issue

# On canary, the endpoint uses site_url() which includes /wp/ on Bedrock:
grep -n "site_url.*/generate" plugins/faustwp/includes/auth/callbacks.php
# Expected (before fix):
#   25: $search_pattern = ':^' . site_url( '/generate', 'relative' ) . ':';

Confirm the fix

# After this PR, home_url() matches the public-facing URL that REQUEST_URI carries:
grep -n "home_url.*/generate\|site_url.*/generate" plugins/faustwp/includes/auth/callbacks.php
# Expected:
#   25: $search_pattern = ':^' . home_url( '/generate', 'relative' ) . ':';

Run the test suite

# PHPCS for the touched file
npm run phpcs --prefix plugins/faustwp -- includes/auth/callbacks.php

# PHPUnit for the auth module
npm run test:php --prefix plugins/faustwp -- --filter=Auth

Checklist

  • Targets canary
  • Changeset added (@faustwp/wordpress-plugin patch)
  • Commit is signed (SSH)
  • Semantic commit prefix with issue reference

On Bedrock-style installs where WordPress core lives under /wp/,
site_url('/generate') returns https://example.com/wp/generate but
$_SERVER['REQUEST_URI'] is still /generate, so the preg_match in
handle_generate_endpoint() never fires and the auth-code redirect
silently breaks.

home_url() returns the public-facing URL (what REQUEST_URI actually
contains), which matches on both standard and Bedrock installs.

Per @josephfusco's guidance on wpengine#2315, which was closed in favor of
this simpler fix — a new filter is not needed, just the correct URL
helper.
@latenighthackathon latenighthackathon requested a review from a team as a code owner April 21, 2026 03:29
@headless-platform-by-wp-engine
Copy link
Copy Markdown

Currently, we do not support the creation of preview deployments based on changes coming from forked repositories.
Learn more about preview environments in our documentation.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

🦋 Changeset detected

Latest commit: c9b579f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@faustwp/wordpress-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

Add filter for search_pattern in handle_generate_endpoint

1 participant