예제 #1
0
// have not been populated in the global scope through something like `sunrise.php`.
if (!isset($current_site) || !isset($current_blog)) {
    $domain = strtolower(stripslashes($_SERVER['HTTP_HOST']));
    if (substr($domain, -3) == ':80') {
        $domain = substr($domain, 0, -3);
        $_SERVER['HTTP_HOST'] = substr($_SERVER['HTTP_HOST'], 0, -3);
    } elseif (substr($domain, -4) == ':443') {
        $domain = substr($domain, 0, -4);
        $_SERVER['HTTP_HOST'] = substr($_SERVER['HTTP_HOST'], 0, -4);
    }
    $path = stripslashes($_SERVER['REQUEST_URI']);
    if (is_admin()) {
        $path = preg_replace('#(.*)/wp-admin/.*#', '$1/', $path);
    }
    list($path) = explode('?', $path);
    $bootstrap_result = ms_load_current_site_and_network($domain, $path, is_subdomain_install());
    if (true === $bootstrap_result) {
        // `$current_blog` and `$current_site are now populated.
    } elseif (false === $bootstrap_result) {
        ms_not_installed($domain, $path);
    } else {
        header('Location: ' . $bootstrap_result);
        exit;
    }
    unset($bootstrap_result);
    $blog_id = $current_blog->blog_id;
    $public = $current_blog->public;
    if (empty($current_blog->site_id)) {
        // This dates to [MU134] and shouldn't be relevant anymore,
        // but it could be possible for arguments passed to insert_blog() etc.
        $current_blog->site_id = 1;
예제 #2
0
 /**
  * @ticket 27884
  */
 public function test_multisite_bootstrap_additional_path_segments()
 {
     global $current_blog;
     $expected = array('network_id' => self::$network_ids['wordpress.org/'], 'site_id' => self::$site_ids['wordpress.org/foo/bar/']);
     add_filter('site_by_path_segments_count', array($this, 'filter_path_segments_to_two'));
     ms_load_current_site_and_network('wordpress.org', '/foo/bar/');
     $actual = array('network_id' => $current_blog->site_id, 'site_id' => $current_blog->blog_id);
     remove_filter('site_by_path_segments_count', array($this, 'filter_path_segments_to_two'));
     ms_load_current_site_and_network(WP_TESTS_DOMAIN, '/');
     $this->assertEqualSetsWithIndex($expected, $actual);
 }