From 591a31a664f4d03c5e406b4680cb72a8753067a9 Mon Sep 17 00:00:00 2001 From: wpmuguru Date: Tue, 12 Jan 2010 21:52:51 +0000 Subject: [PATCH] add is_main_site() function, See #11644 git-svn-id: http://svn.automattic.com/wordpress/trunk@12714 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 05ae143dd9..5310b976ea 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3461,6 +3461,28 @@ function set_site_transient($transient, $value, $expiration = 0) { } } +/** + * is main site + * + * + * @since 3.0.0 + * @package WordPress + * + * @param int $blog_id optional blog id to test (default current blog) + * @return bool True if not multisite or $blog_id is main site + */ +function is_main_site( $blog_id = '' ) { + global $current_site, $current_blog; + + if ( !is_multisite() ) + return true; + + if ( !$blog_id ) + $blog_id = $current_blog->blog_id; + + return $blog_id == $current_site->blog_id; +} + /** * gmt_offset modification for smart timezone handling *