-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-support-manager.php
More file actions
275 lines (239 loc) · 6.82 KB
/
wp-support-manager.php
File metadata and controls
275 lines (239 loc) · 6.82 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<?php
/*
Plugin Name: WP Support Manager
Plugin URI: http://sabbir.pro/
Description: A fully ticket based customer support system for WordPress
Version: 1.0.0
Author: Sabbir Ahmed, Rafsun Chowdhury
Author URI: http://sabbir.pro/
License: GPL2
*/
/**
* Copyright (c) YEAR Sabbir Ahmed (email: sabbir.080170@gmail.com). All rights reserved.
*
* Released under the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*
* This is an add-on for WordPress
* http://wordpress.org/
*
* **********************************************************************
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* **********************************************************************
*/
// don't call the file directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* WP_Support_Manager class
*
* @class WP_Support_Manager The class that holds the entire WP_Support_Manager plugin
*/
class WP_Support_Manager {
/**
* Plugin version
*
* @var string
*/
public $version = '1.0.0';
/**
* Holds all class instances
*
* @var array
*/
private $container = array();
/**
* Constructor for the WP_Support_Manager class
*
* Sets up all the appropriate hooks and actions
* within our plugin.
*
* @uses register_activation_hook()
* @uses register_deactivation_hook()
* @uses is_admin()
* @uses add_action()
*/
public function __construct() {
// Define all constant
$this->define_constant();
register_activation_hook( __FILE__, array( $this, 'activate' ) );
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
add_action( 'plugins_loaded', array( $this, 'init_plugin' ) );
}
/**
* Initializes the WP_Support_Manager() class
*
* Checks for an existing WP_Support_Manager() instance
* and if it doesn't find one, creates it.
*/
public static function init() {
static $instance = false;
if ( ! $instance ) {
$instance = new WP_Support_Manager();
}
return $instance;
}
/**
* Magic getter to bypass referencing plugin.
*
* @param $prop
*
* @return mixed
*/
public function __get( $prop ) {
if ( array_key_exists( $prop, $this->container ) ) {
return $this->container[ $prop ];
}
return $this->{$prop};
}
/**
* Magic isset to bypass referencing plugin.
*
* @param $prop
*
* @return mixed
*/
public function __isset( $prop ) {
return isset( $this->{$prop} ) || isset( $this->container[ $prop ] );
}
/**
* Placeholder for activation function
*
* Nothing being called here yet.
*/
public function activate() {
require_once WP_SUPPORT_MANAGER_INC_PATH . '/class-install.php';
$installer = new WPSM_Install();
$installer->do_install();
}
/**
* Placeholder for deactivation function
*
* Nothing being called here yet.
*/
public function deactivate() {
}
/**
* Defined all constant
*
* @return void
*/
private function define_constant() {
define( 'WP_SUPPORT_MANAGER_VERSION', $this->version );
define( 'WP_SUPPORT_MANAGER_FILE', __FILE__ );
define( 'WP_SUPPORT_MANAGER_PATH', dirname( WP_SUPPORT_MANAGER_FILE ) );
define( 'WP_SUPPORT_MANAGER_INC_PATH', WP_SUPPORT_MANAGER_PATH . '/includes' );
define( 'WP_SUPPORT_MANAGER_ASSETS', plugins_url( '/assets', __FILE__ ) );
}
/**
* Get the template path.
*
* @since 1.0.0
*
* @return string
*/
public function template_path() {
return apply_filters( 'wpsm_template_path', 'wpsupport/' );
}
/**
* Get the plugin path.
*
* @since 1.0.0
*
* @return string
*/
public function plugin_path() {
return untrailingslashit( plugin_dir_path( WP_SUPPORT_MANAGER_FILE ) );
}
/**
* Load the plugin after WP User Frontend is loaded
*
* @return void
*/
public function init_plugin() {
$this->includes();
$this->init_hooks();
do_action( 'wp_support_manager_loaded', $this );
}
/**
* Includes all files
*
* @since 1.0.0
*
* @return void
**/
public function includes() {
if ( is_admin() ) {
require_once WP_SUPPORT_MANAGER_INC_PATH . '/admin/class-admin.php';
} else {
require_once WP_SUPPORT_MANAGER_INC_PATH . '/class-frontend.php';
}
require_once WP_SUPPORT_MANAGER_INC_PATH . '/class-form-handler.php';
require_once WP_SUPPORT_MANAGER_INC_PATH . '/class-scripts.php';
require_once WP_SUPPORT_MANAGER_INC_PATH . '/class-rewrites.php';
require_once WP_SUPPORT_MANAGER_INC_PATH . '/class-core.php';
require_once WP_SUPPORT_MANAGER_INC_PATH . '/class-ticket.php';
require_once WP_SUPPORT_MANAGER_INC_PATH . '/functions.php';
require_once WP_SUPPORT_MANAGER_INC_PATH . '/core-functions.php';
}
/**
* Init all filters
*
* @since 1.0.0
*
* @return void
**/
public function init_hooks() {
// Localize our plugin
add_action( 'init', array( $this, 'localization_setup' ) );
// initialize the classes
add_action( 'init', array( $this, 'init_classes' ) );
}
/**
* Inistantiate all classes
*
* @since 1.0.0
*
* @return void
**/
public function init_classes() {
if ( is_admin() ) {
new WPSM_Admin();
} else {
new WPSM_Frontend();
}
$this->container['scripts'] = new WPSM_Scripts();
$this->container['ticket'] = new WPSM_Ticket();
}
/**
* Initialize plugin for localization
*
* @since 1.0.0
*
* @uses load_plugin_textdomain()
*/
public function localization_setup() {
load_plugin_textdomain( 'wp-support-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
}
/**
* Initialize the plugin
*
* @return WP_Support_Manager
*/
function wpsm() {
return WP_Support_Manager::init();
}
// Lets go..
wpsm();