fix[faustwp]: (#1872) add filter for search_pattern in handle_generate_endpoint#2315
Conversation
…_generate_endpoint Add apply_filters( 'faustwp_generate_endpoint_search_pattern' ) so non-standard WordPress installations like Bedrock can customize the regex pattern used to match the /generate endpoint. Bedrock returns /wp/generate from site_url() but REQUEST_URI only contains /generate, causing the preg_match to fail and previews to 404. The filter lets users adjust the pattern without modifying the plugin source. Closes wpengine#1872
|
Currently, we do not support the creation of preview deployments based on changes coming from forked repositories. |
🦋 Changeset detectedLatest commit: 8c27dce The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Thanks for the contribution! I don't think we need a new filter here. The fix is to use $search_pattern = ':^' . home_url( '/generate', 'relative' ) . ':';
See also #1897 which addresses the same class of Bedrock subdirectory issue on the JS side. |
|
Currently, we do not support the creation of preview deployments based on changes coming from forked repositories. |
Description
Non-standard WordPress installations like Bedrock use a different directory structure where
site_url()returns a path with a/wp/prefix (e.g./wp/generate) but$_SERVER['REQUEST_URI']contains only/generate. This causes thepreg_matchinhandle_generate_endpoint()to fail, resulting in 404 errors when previewing content.This PR adds an
apply_filters()call on$search_patternso sites with non-standard directory structures can adjust the matching pattern without modifying the plugin source.Usage example for Bedrock:
Related Issues
Closes #1872
Testing
Confirm the issue (before the fix)
1. Verify no filter exists on
$search_pattern:2. Verify
$search_patternusessite_url()which includes subdirectories on Bedrock:Confirm the fix
3. Verify the filter is applied after
$search_patternis constructed:4. Verify the docblock follows WordPress standards (@SInCE, @param):
Run the test suites
phpcs — confirms the filter follows WordPress coding standards:
JS tests — confirms no regressions:
WordPress PHPUnit — confirms plugin functionality: