-
Notifications
You must be signed in to change notification settings - Fork 5
/
bp-multinetwork.php
93 lines (80 loc) · 2.22 KB
/
bp-multinetwork.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Plugin Name: BuddyPress Multi Network
* Plugin URI: http://buddydev.com/plugins/buddypress-multi-network/
* Version: 1.0.4
* Author: Brajesh Singh
* Author URI: https://buddydev.com
* Contributors: Zipline, sjregan
* Description: Helps you to Build multiple BuddyPress network on a WordPress Multisite/BuddyPress Install
* License: GPL
*
* @package buddypress-multi-network
*/
// Do not allow direct access over web.
defined( 'ABSPATH' ) || exit;
define( 'BP_MNETWORK_DIR', plugin_dir_path( __FILE__ ) );
/**
* Class BPMultiNetworkHelper
*/
class BP_Multi_Network_Helper {
/**
* Singleton.
*
* @var BP_Multi_Network_Helper
*/
private static $instance;
/**
* Get singleton instance.
*
* @return BP_Multi_Network_Helper
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor.
*/
private function __construct() {
// if MULTIBLOG is not enabled, dont do anything fancy.
add_action( 'bp_loaded', array( $this, 'setup_network_component' ), 1 );
include_once( BP_MNETWORK_DIR . 'core/class-bp-multi-network-actions.php' );
include_once( BP_MNETWORK_DIR . 'core/class-bp-multi-network-filters.php' );
include_once( BP_MNETWORK_DIR . 'core/class-bp-multi-network-users.php' );
include_once( BP_MNETWORK_DIR . 'core/bp-multi-network-user-functions.php' );
// to install and create required tables.
if ( is_network_admin() ) {
include_once BP_MNETWORK_DIR . 'core/bp-multi-network-install.php';
}
}
/**
* Load.
*/
public function setup_network_component() {
include_once BP_MNETWORK_DIR . 'class-bp-multi-network-component.php';
buddypress()->mnetwork = BP_Multi_Network_Component::get_instance();
}
/**
* Get the user table name.
*
* @return string
*/
public function get_table_name() {
global $wpdb;
return $wpdb->base_prefix . 'bp_mnetwork_users';
}
}
BP_Multi_Network_Helper::get_instance();
// backward compatibility.
class_alias( 'BP_Multi_Network_Helper', 'BPMultiNetworkHelper' );
/**
* Get the user->network mapping table.
*
* @return string
*/
function mnetwork_get_table_name() {
return BP_Multi_Network_Helper::get_instance()->get_table_name();
}