From 28f1f83db10ec517d881cb51508760f9ec4f5720 Mon Sep 17 00:00:00 2001 From: Arron Gibson Date: Wed, 4 Dec 2024 09:30:13 -0500 Subject: [PATCH] Adding a filter for optional change of public redirect status codes (#1985) * Adding a filter for optional change of public redirect status codes adding support for users to change the redirect status code from a `302` to another code of their choice, likely `301`. * Adding Changeset --- .changeset/tasty-walls-thank.md | 5 +++++ plugins/faustwp/includes/deny-public-access/callbacks.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/tasty-walls-thank.md diff --git a/.changeset/tasty-walls-thank.md b/.changeset/tasty-walls-thank.md new file mode 100644 index 000000000..a988baa93 --- /dev/null +++ b/.changeset/tasty-walls-thank.md @@ -0,0 +1,5 @@ +--- +'@faustwp/wordpress-plugin': minor +--- + +Added new filter `faustwp_public_redirect_status_code`, allowing WordPress plugins and themes to choose the [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) to use when generating redirects when the [enable public route redirects](https://faustjs.org/docs/faustwp/settings#enabling-public-route-redirects) setting is active. diff --git a/plugins/faustwp/includes/deny-public-access/callbacks.php b/plugins/faustwp/includes/deny-public-access/callbacks.php index 052dca2a2..c5eac2c6d 100644 --- a/plugins/faustwp/includes/deny-public-access/callbacks.php +++ b/plugins/faustwp/includes/deny-public-access/callbacks.php @@ -60,7 +60,7 @@ function deny_public_access() { // Get the request uri with query params. $request_uri = home_url( add_query_arg( null, null ) ); - $response_code = 302; + $response_code = apply_filters( 'faustwp_public_redirect_status_code', 302 ); $redirect_url = str_replace( trailingslashit( get_home_url() ), $frontend_uri, $request_uri ); $protocols = array( 'http', 'https' );