Skip to content

General: Add "doing it wrong" notice for encoded URLs in add_query_arg() #8817

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,14 @@ function add_query_arg( ...$args ) {
}
}

if ( preg_match( '/&(#\d+|[a-zA-Z]+);/', $uri ) ) {
_doing_it_wrong(
__FUNCTION__,
__( 'Passing encoded URLs to add_query_arg() is not recommended. Please pass a non-encoded URL to add_query_arg().' ),
'6.8.2'
);
}

$frag = strstr( $uri, '#' );
if ( $frag ) {
$uri = substr( $uri, 0, -strlen( $frag ) );
Expand Down
Loading