mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Introduce get_site_by_path() and further rewrite the site detection process for multisite.
This is the first big step to supporting arbitrary domains and paths. In this new approach, sites are detected first where possible, then the network is inferred. Allows filtering for arbitrary path segments, smooths out some weirdness, and removes various restrictions. A sunrise plugin could do much of its work by adding filters, if those are even needed. see #27003. git-svn-id: https://develop.svn.wordpress.org/trunk@27359 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1220,6 +1220,45 @@ class Tests_MS extends WP_UnitTestCase {
|
||||
get_network_by_path( 'site1.wordpress.net', '/three/' )->id );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 27003
|
||||
*/
|
||||
function test_get_site_by_path() {
|
||||
$ids = array(
|
||||
'wordpress.org/' => array( 'domain' => 'wordpress.org', 'path' => '/' ),
|
||||
'wordpress.org/foo/' => array( 'domain' => 'wordpress.org', 'path' => '/foo/' ),
|
||||
'wordpress.org/foo/bar/' => array( 'domain' => 'wordpress.org', 'path' => '/foo/bar/' ),
|
||||
'make.wordpress.org/' => array( 'domain' => 'make.wordpress.org', 'path' => '/' ),
|
||||
'make.wordpress.org/foo/' => array( 'domain' => 'make.wordpress.org', 'path' => '/foo/' ),
|
||||
);
|
||||
|
||||
foreach ( $ids as &$id ) {
|
||||
$id = $this->factory->blog->create( $id );
|
||||
}
|
||||
unset( $id );
|
||||
|
||||
$this->assertEquals( $ids['wordpress.org/'],
|
||||
get_site_by_path( 'wordpress.org', '/notapath/' )->blog_id );
|
||||
|
||||
$this->assertEquals( $ids['wordpress.org/foo/bar/'],
|
||||
get_site_by_path( 'wordpress.org', '/foo/bar/baz/' )->blog_id );
|
||||
|
||||
$this->assertEquals( $ids['wordpress.org/foo/bar/'],
|
||||
get_site_by_path( 'wordpress.org', '/foo/bar/baz/', 3 )->blog_id );
|
||||
|
||||
$this->assertEquals( $ids['wordpress.org/foo/bar/'],
|
||||
get_site_by_path( 'wordpress.org', '/foo/bar/baz/', 2 )->blog_id );
|
||||
|
||||
$this->assertEquals( $ids['wordpress.org/foo/'],
|
||||
get_site_by_path( 'wordpress.org', '/foo/bar/baz/', 1 )->blog_id );
|
||||
|
||||
$this->assertEquals( $ids['wordpress.org/'],
|
||||
get_site_by_path( 'wordpress.org', '/', 0 )->blog_id );
|
||||
|
||||
$this->assertEquals( $ids['make.wordpress.org/foo/'],
|
||||
get_site_by_path( 'make.wordpress.org', '/foo/bar/baz/qux/', 4 )->blog_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 20601
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user