| 226 | | // Define on which blog ID BuddyPress should run |
| 227 | | if ( !defined( 'BP_ROOT_BLOG' ) ) { |
| 228 | | |
| 229 | | // Default to 1 |
| 230 | | $root_blog_id = 1; |
| 231 | | |
| 232 | | // Root blog is the main site on this network |
| 233 | | if ( is_multisite() && !defined( 'BP_ENABLE_MULTIBLOG' ) ) { |
| 234 | | $current_site = get_current_site(); |
| 235 | | $root_blog_id = $current_site->blog_id; |
| 236 | | |
| 237 | | // Root blog is every site on this network |
| 238 | | } elseif ( is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) ) { |
| 239 | | $root_blog_id = get_current_blog_id(); |
| 240 | | } |
| 241 | | |
| 242 | | define( 'BP_ROOT_BLOG', $root_blog_id ); |
| 243 | | } |
| 244 | | |
| | 241 | // Define on which blog ID BuddyPress should run |
| | 242 | if ( ! defined( 'BP_ROOT_BLOG' ) ) { |
| | 243 | |
| | 244 | // Default to use current blog ID |
| | 245 | // Fulfills non-network installs and BP_ENABLE_MULTIBLOG installs |
| | 246 | $root_blog_id = get_current_blog_id(); |
| | 247 | |
| | 248 | // Multisite check |
| | 249 | if ( is_multisite() ) { |
| | 250 | |
| | 251 | // Multiblog isn't enabled |
| | 252 | if ( ! defined( 'BP_ENABLE_MULTIBLOG' ) || ( defined( 'BP_ENABLE_MULTIBLOG' ) && (int) constant( 'BP_ENABLE_MULTIBLOG' ) === 0 ) ) { |
| | 253 | // Check to see if BP is network-activated |
| | 254 | // We're not using is_plugin_active_for_network() b/c you need to include the |
| | 255 | // /wp-admin/includes/plugin.php file in order to use that function. |
| | 256 | |
| | 257 | // get network-activated plugins |
| | 258 | $plugins = get_site_option( 'active_sitewide_plugins'); |
| | 259 | |
| | 260 | // basename |
| | 261 | $basename = plugin_basename( constant( 'BP_PLUGIN_DIR' ) . 'bp-loader.php' ); |
| | 262 | |
| | 263 | // plugin is network-activated; use main site ID instead |
| | 264 | if ( isset( $plugins[ $basename ] ) ) { |
| | 265 | $current_site = get_current_site(); |
| | 266 | $root_blog_id = $current_site->blog_id; |
| | 267 | } |
| | 268 | } |
| | 269 | |
| | 270 | } |
| | 271 | |
| | 272 | define( 'BP_ROOT_BLOG', $root_blog_id ); |
| | 273 | } |
| | 274 | |