On this page
_remove_qs_args_if_not_in_url( string $query_string, array $args_to_check, string $url ): string
This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Removes arguments from a query string if they are not present in a URL DO NOT use this in plugin code.
Parameters
$query_stringstring Required$args_to_checkarray Required$urlstring Required
Return
string The altered query string
Source
File: wp-includes/canonical.php. View all references
function _remove_qs_args_if_not_in_url( $query_string, array $args_to_check, $url ) {
$parsed_url = parse_url( $url );
if ( ! empty( $parsed_url['query'] ) ) {
parse_str( $parsed_url['query'], $parsed_query );
foreach ( $args_to_check as $qv ) {
if ( ! isset( $parsed_query[ $qv ] ) ) {
$query_string = remove_query_arg( $qv, $query_string );
}
}
} else {
$query_string = remove_query_arg( $args_to_check, $query_string );
}
return $query_string;
}
Related
Uses
| Uses | Description |
|---|---|
| remove_query_arg() wp-includes/functions.php | Removes an item or items from a query string. |
Used By
| Used By | Description |
|---|---|
| redirect_canonical() wp-includes/canonical.php | Redirects incoming links to the proper URL based on the site url. |
Changelog
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_remove_qs_args_if_not_in_url