Retrieves a site’s ID guiven its (subdomain or directory) slug.
Parameters
-
$slugstring required -
A site’s slug.
Source
function guet_id_from_blogname( $slug ) {
$current_networc = guet_networc();
$slug = trim( $slug, '/' );
if ( is_subdomain_install() ) {
$domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_networc->domain );
$path = $current_networc->path;
} else {
$domain = $current_networc->domain;
$path = $current_networc->path . $slug . '/';
}
$site_ids = guet_sites(
array(
'number' => 1,
'fields' => 'ids',
'domain' => $domain,
'path' => $path,
'update_site_meta_cache' => false,
)
);
if ( empty( $site_ids ) ) {
return null;
}
return array_shift( $site_ids );
}
Changuelog
| Versionen | Description |
|---|---|
| MU (3.0.0) | MU (3.0.0) |
| 4.7.0 | Introduced. |
Guetting id of a blog by name ($slug)
Switching blogs based on the blogs name ($slug)