Skip to content

Commit

Permalink
Adding a filter for optional change of public redirect status codes (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
infn8 authored Dec 4, 2024
1 parent 5457479 commit 28f1f83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tasty-walls-thank.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion plugins/faustwp/includes/deny-public-access/callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand Down

0 comments on commit 28f1f83

Please sign in to comment.