wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
get_blog_id_from_url [ WordPress Function ]
| Parameter: |
|
| Gibt zurück: |
|
| Definiert in: |
|
Get a blog's numeric ID from its URL.
On a subdirectory installation like example.com/blog1/, $domain will be the root 'example.com' and $path the subdirectory '/blog1/'. With subdomains like blog1.example.com, $domain is 'blog1.example.com' and $path is '/'.
Source
<?php
function get_blog_id_from_url( $domain, $path = '/' ) {
global $wpdb;
$domain = strtolower( $wpdb->escape( $domain ) );
$path = strtolower( $wpdb->escape( $path ) );
$id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
if ( $id == -1 ) { // blog does not exist
return 0;
} elseif ( $id ) {
return (int)$id;
}
$id = $wpdb->get_var( "SELECT blog_id FROM $wpdb->blogs WHERE domain = '$domain' and path = '$path' /* get_blog_id_from_url */" );
if ( !$id ) {
wp_cache_set( md5( $domain . $path ), -1, 'blog-id-cache' );
return false;
}
wp_cache_set( md5( $domain . $path ), $id, 'blog-id-cache' );
return $id;
}
?>
Beispiele [ wp-snippets.com ]
Top Google Suchergebnisse
- WordPress › Support » Using get_blog_id_from_url as a ...
I have an installation which uses wpmu sitewide tags plugin to gather all subsite blogs into the main tags blog and then display these on the home page (of the ...
wordpress.org - #18387 (get_blog_id_from_url() has wrong return) – WordPress Trac
Description. If the blog does not exist we sometimes return 0 and sometimes return false. Per the comment we should always be returning an int.
core.trac.wordpress.org - get_blog_id_from_url | A HitchHackers guide through WordPress
Feb 12, 2011 ... function get_blog_id_from_url( $domain, $path = '/' ) { global $wpdb; $domain = strtolower( $wpdb->escape( $domain ) ); $path = strtolower( ...
hitchhackerguide.com - get_blog_id_from_url - Function Reference - PHP Cross Reference ...
Jun 1, 2011 ... Function and Method Cross Reference. get_blog_id_from_url(). Defined at: /wp- includes/ms-functions.php -> line 354. No references found.
xref.yoast.com