From 8c27dce4482b0a2c44293105bab4c1b67b2a11b6 Mon Sep 17 00:00:00 2001 From: latenighthackathon Date: Thu, 2 Apr 2026 23:56:11 -0500 Subject: [PATCH] fix[faustwp]: (#1872) add filter for search_pattern in handle_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 #1872 --- .changeset/filter-generate-endpoint.md | 5 +++++ plugins/faustwp/includes/auth/callbacks.php | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 .changeset/filter-generate-endpoint.md diff --git a/.changeset/filter-generate-endpoint.md b/.changeset/filter-generate-endpoint.md new file mode 100644 index 000000000..830cb9a56 --- /dev/null +++ b/.changeset/filter-generate-endpoint.md @@ -0,0 +1,5 @@ +--- +"@faustwp/wordpress-plugin": patch +--- + +fix[faustwp]: add `faustwp_generate_endpoint_search_pattern` filter to handle_generate_endpoint() for non-standard WordPress installations diff --git a/plugins/faustwp/includes/auth/callbacks.php b/plugins/faustwp/includes/auth/callbacks.php index da82180d0..10c5dbe02 100644 --- a/plugins/faustwp/includes/auth/callbacks.php +++ b/plugins/faustwp/includes/auth/callbacks.php @@ -23,6 +23,17 @@ */ function handle_generate_endpoint() { $search_pattern = ':^' . site_url( '/generate', 'relative' ) . ':'; + /** + * Filter the search pattern used to match the generate endpoint. + * + * Useful for non-standard WordPress installations (e.g. Bedrock) where + * site_url() includes a subdirectory that does not appear in REQUEST_URI. + * + * @since 1.8.7 + * + * @param string $search_pattern The regex pattern used to match the generate endpoint. + */ + $search_pattern = apply_filters( 'faustwp_generate_endpoint_search_pattern', $search_pattern ); if ( ! preg_match( $search_pattern, $_SERVER['REQUEST_URI'] ) ) { // phpcs:ignore WordPress.Security return;