Make WordPress Core

Opened 6 weeks ago

Closed 6 weeks ago

Last modified 4 weeks ago

#62320 closed enhancement (invalid)

Update `wp_login_url` and `wp_logout_url` to Use `network_site_url` Instead of `site_url`

Reported by: debarghyabanerjee's profile 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

Trac Ticket: Core-62320

## Description

  • This pull request updates the wp_login_url and wp_logout_url functions to use network_site_url() instead of site_url(). This change enhances compatibility with multisite environments, ensuring that these functions correctly generate URLs based on the network root when applicable.

## Background

  • In WordPress multisite setups, network_site_url() is designed to handle URL generation based on the network’s primary site URL, while falling back to site_url() in single-site environments. Currently, wp_login_url and wp_logout_url use site_url(), which can lead to inconsistencies in multisite setups where URLs need to point to the network’s root URL.

## Changes Made

  • Replaced site_url() with network_site_url() in both wp_login_url and wp_logout_url functions.

## Impact

  • This change should be backward compatible and will primarily benefit multisite installations by ensuring URLs are correctly generated based on the network root.

#2 @debarghyabanerjee
6 weeks ago

  • Resolution set to invalid
  • Status changed from new to closed

#3 @desrosj
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.

#4 @debarghyabanerjee
4 weeks ago

Hi @desrosj

After carefully observing, I found that site_url does the perfect job where it has been used. So, found this ticket invalid and hence closed this.

Note: See TracTickets for help on using tickets.