[wp-trac] [WordPress Trac] #62320: Update `wp_login_url` and `wp_logout_url` to Use `network_site_url` Instead of `site_url`
WordPress Trac
noreply at wordpress.org
Tue Oct 29 11:14:02 UTC 2024
#62320: Update `wp_login_url` and `wp_logout_url` to Use `network_site_url` Instead
of `site_url`
-------------------------------+------------------------------------------
Reporter: debarghyabanerjee | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords: needs-patch needs-unit-tests
Focuses: |
-------------------------------+------------------------------------------
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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62320>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list