#62320 closed enhancement (invalid)
Update `wp_login_url` and `wp_logout_url` to Use `network_site_url` Instead of `site_url`
Reported by: | debarghyabanerjee | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | General | Keywords: | needs-unit-tests has-patch reporter-feedback |
Focuses: | Cc: |
Description
Currently, the wp_login_url
and wp_logout_url
functions use site_url()
to generate the login and logout URLs. However, in multisite environments, it’s more appropriate to use network_site_url() as it dynamically determines if the current setup is a multisite. If it’s not a multisite, network_site_url()
internally falls back to site_url()
, ensuring compatibility for single-site installations as well.
Updating these functions to use network_site_url()
will provide better compatibility in multisite environments, ensuring login/logout URLs are generated based on the network root when necessary.
network_site_url()
checks the environment and returns the correct URL based on whether the site is part of a multisite network:
if ( ! is_multisite() ) { return site_url( $path, $scheme ); }
This adjustment will prevent potential inconsistencies in URL handling across multisite setups.
Change History (4)
This ticket was mentioned in PR #7678 on WordPress/wordpress-develop by @debarghyabanerjee.
6 weeks ago
#1
- Keywords has-patch added; needs-patch removed
#3
@
4 weeks ago
- Keywords reporter-feedback added
- Milestone Awaiting Review deleted
Hi @debarghyabanerjee,
Just checking to see if you intended to close this ticket and PR since there's no update on either. If it was intentional, please provide a brief explanation why you chose that action for anyone that comes across this ticket in the future.
Trac Ticket: Core-62320
## Description
wp_login_url
andwp_logout_url
functions to usenetwork_site_url()
instead ofsite_url()
. This change enhances compatibility with multisite environments, ensuring that these functions correctly generate URLs based on the network root when applicable.## Background
site_url()
in single-site environments. Currently,wp_login_url
andwp_logout_url
usesite_url()
, which can lead to inconsistencies in multisite setups where URLs need to point to the network’s root URL.## Changes Made
site_url()
withnetwork_site_url()
in both wp_login_url andwp_logout_url
functions.## Impact