wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi
get_id_from_blogname › WordPress Function
Dan/a
Deprecaton/a
› get_id_from_blogname ( $slug )
| Parametri: |
|
| Ritorna: |
|
| Definito a: |
|
| Codex: | |
| ChangeLog: |
|
Retrieves a site's ID given its (subdomain or directory) slug.
Funzioni correlate: get_date_from_gmt, get_blog_id_from_url, get_dynamic_block_names, get_gmt_from_date, get_user_id_from_string
Sorgenti
function get_id_from_blogname( $slug ) {
$current_network = get_network();
$slug = trim( $slug, '/' );
if ( is_subdomain_install() ) {
$domain = $slug . '.' . preg_replace( '|^www\.|', '', $current_network->domain );
$path = $current_network->path;
} else {
$domain = $current_network->domain;
$path = $current_network->path . $slug . '/';
}
$site_ids = get_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 );
}