get_blog_list mapped domains

in the case of a multisite network being on mydomain.tld with a sub-site of blog1.mydomain.tld and a mapped domain of blog1.tld

$blog_list = get_blog_list();
foreach ($blog_list as $blog) {
    echo $blog['domain'];  //returns the blog1.mydomain.tld
}

i'm creating a plugin that needs to list the mapped domains of each site. how would i list the the mapped domains for each site?

  • Mason

    Hiya!

    Stolen from the domain mapping plugin:

    function build_domain_mapping_cache() {
    
    	global $current_site;
    
    	if(empty($this->mappings)) {
    
    		$mappings = $this->db->get_results( "SELECT blog_id, domain FROM {$this->dmt} /* domain mapping */" );
    		foreach($mappings as $map) {
    			if($current_site->path == '/') {
    				$this->mappings[$map->blog_id][] = "<a href='http://" . $map->domain . $current_site->path . "'>" . $map->domain . "</a>";
    			} else {
    				$this->mappings[$map->blog_id][] = "<a href='http://" . $map->domain . $current_site->path . "'>" . $map->domain . $current_site->path . "</a>";
    			}
    		}
    
    	}
    
    }

    You should be able to modify that to get the mapped domain. Thanks!