Make WordPress Core


Ignore:
Timestamp:
05/04/2024 07:23:31 PM (7 months ago)
Author:
johnbillion
Message:

Bootstrap/Load: Add support for custom ports in multisite site addresses.

This allows a Multisite network to use an address that includes a port name, such as example.com:1234, and adds support for this to the local development environment too. You can now run a Multisite installation on the local development environment, for example at localhost:8889.

This also fixes some bugs with running a single site installation on a port, and updates the testing infrastructure so that the whole test suite runs both with and without a port number.

Props djzone, scribu, nacin, ipstenu, F J Kaiser, jeremyfelt, johnjamesjacoby, spacedmonkey, PerS, Clorith, Blackbam, enrico.sorcinelli, Jules Colle, obliviousharmony, desrosj, johnbillion

Fixes #21077, #52088

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/network.php

    r57793 r58097  
    149149    }
    150150
    151     $hostname  = get_clean_basedomain();
    152     $has_ports = strstr( $hostname, ':' );
    153     if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ), true ) ) ) {
    154         wp_admin_notice(
    155             '<strong>' . __( 'Error:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ),
    156             array(
    157                 'additional_classes' => array( 'error' ),
    158             )
    159         );
    160 
    161         echo '<p>' . sprintf(
    162             /* translators: %s: Port number. */
    163             __( 'You cannot use port numbers such as %s.' ),
    164             '<code>' . $has_ports . '</code>'
    165         ) . '</p>';
    166         echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Go to Dashboard' ) . '</a>';
    167         echo '</div>';
    168         require_once ABSPATH . 'wp-admin/admin-footer.php';
    169         die();
    170     }
     151    // Strip standard port from hostname.
     152    $hostname = preg_replace( '/(?::80|:443)$/', '', get_clean_basedomain() );
    171153
    172154    echo '<form method="post">';
Note: See TracChangeset for help on using the changeset viewer.