Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filtering wp_redirect #50

Merged
merged 1 commit into from
Nov 10, 2023
Merged

Conversation

BrianHenryIE
Copy link
Contributor

Currently, if the wp_redirect filter is used and returns false (as it is designed to accommodate) the wp_redirect() function returns and exit is run anyway.

This PR implements the code pattern suggested in the wp_redirect() php docblock which does not exit if the function returns early with false. See: pluggable.php

It also changes from using wp_redirect() to wp_safe_redirect() – AIUI the preferred function for local redirects.

// Do not redirect when activating `sqlite-database-integration` plugin.
add_filter( 'wp_redirect', function( string $location, int $status ): string|bool {
	if( str_ends_with( $location, 'sqlite-integration' ) ) {
		return false;
	}
	return $location;
}, 10, 2);

Allows #49 to be handled by WP CLI itself.

@swissspidy swissspidy merged commit ed9264b into WordPress:main Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants