-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbp-chat.php
153 lines (108 loc) · 2.88 KB
/
bp-chat.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/*
Plugin Name: BP Chat
Plugin URI: http://buddydev.com/plugins/bp-chat/
Description: just a begining, this beta version just showcases some of the features, More features coming by end of March 2011
Version: 1.1 trunk
Revision Date:February 13, 2013
Requires at least: wp 3.3, BuddyPress 1.5+
Tested up to:WordPress 3.5+BuddyPress 1.6.2
Author: Brajesh Singh
Author URI: http://buddydev.com/members/sbrajesh
*/
define ( 'BP_CHAT_DB_VERSION', 36 );
class BP_Chat_Helper {
private static $instance;
private $url;
private $path;
public $table_name_users;
public $table_name_channels;
public $table_name_messages;
public $table_name_channel_users;
private function __construct() {
add_action( 'bp_loaded', array( $this, 'setup' ), 5 );
add_action( 'bp_loaded', array( $this, 'load' ) );
}
/**
*
* @return BP_Chat_Helper
*/
public static function get_instance() {
if( ! isset( self:: $instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
public function setup() {
$this->path = plugin_dir_path( __FILE__ );
$this->url = plugin_dir_url( __FILE__ );
//setup tables
$this->setup_table_names();
}
private function setup_table_names() {
$table_prefix = bp_core_get_table_prefix();
$this->table_name_users = $table_prefix . 'bp_chat_users';
$this->table_name_channels = $table_prefix . 'bp_chat_channels';
$this->table_name_channel_users = $table_prefix . 'bp_chat_channel_users';
$this->table_name_messages = $table_prefix . 'bp_chat_messages';
}
/**
* Load required files
*
*/
public function load() {
//if we are on a multisite environment and this is not the main site
//do not load this plugin
if( is_multisite() && ! is_main_site() ) {
return;//do not load chat plugin
}
$path = $this->get_path();
$files = array(
'assets/asset-loader.php',
'core/functions.php',
'core/actions.php',
'core/ajax.php',
'core/hooks.php',
'core/template.php',
'core/cron.php',
'core/users/functions.php',
'core/channels/class-channel.php',
'core/channels/functions.php',
'core/messages/class-message.php',
'core/messages/functions.php',
'includes/bp-chat-ajax.php',
'includes/chat-bar.php',
'admin/install.php'
);
if( is_admin() ) {
}
foreach( $files as $file ) {
require_once $path . $file ;
}
do_action( 'bpchat_loaded' );
}
/**
* URL to the bp-chat plugin directory with trailing slash
*
* @return string url
*/
public function get_url() {
return $this->url;
}
/**
* File system absolute path to the bp chat plugin directory with trailing slash
* @return string
*/
public function get_path() {
return $this->path;
}
}
/**
* Singleton instance
*
* @return BP_Chat_Helper
*/
function bp_chat() {
return BP_Chat_Helper::get_instance();
}
bp_chat();