Make WordPress Core


Ignore:
Timestamp:
02/13/2014 11:06:12 PM (10 years ago)
Author:
nacin
Message:

Multisite: Add get_network_by_path() and wp_get_network() to begin cleanup of multisite load.

Tries to get network detection under control by simplifying wpmu_current_site(). It now also pops off each subdomain to find a more general match. Adds unit tests for get_network_by_path() and a new network factory for unit tests.

Much of this is likely to change in 3.9 as more of ms-load.php and ms-settings.php gets hacked to bits.

props jeremyfelt.
see #27003.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-settings.php

    r21581 r27178  
    3838
    3939    $domain = rtrim( $domain, '.' );
    40     $cookie_domain = $domain;
    41     if ( substr( $cookie_domain, 0, 4 ) == 'www.' )
    42         $cookie_domain = substr( $cookie_domain, 4 );
    4340
    4441    $path = preg_replace( '|([a-z0-9-]+.php.*)|', '', $_SERVER['REQUEST_URI'] );
     
    4744
    4845    $current_site = wpmu_current_site();
     46    $current_site->cookie_domain = $current_site->domain;
     47    if ( 'www.' === substr( $current_site->cookie_domain, 0, 4 ) ) {
     48        $current_site->cookie_domain = substr( $current_site->cookie_domain, 4 );
     49    }
     50
    4951    if ( ! isset( $current_site->blog_id ) )
    5052        $current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) );
Note: See TracChangeset for help on using the changeset viewer.