-
Notifications
You must be signed in to change notification settings - Fork 2
/
give-me-answer-lite.php
248 lines (208 loc) · 8.18 KB
/
give-me-answer-lite.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
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
<?php
/**
* Plugin Name: Give Me Answer Lite
* Description: A WordPress plugin to build an Question Answer system for support, asking and communicate with your customer
* Author: Siavash Ebrahimi
* Author URI: http://www.siaeb.com/
* Version: 1.0
* Text Domain: give-me-answer-lite
* Domain Path: languages/
* @since 1.0
*/
class Give_Me_Answer_Lite {
private $last_update = 1563261015; //last update time of the plugin
private function __construct() {
$this->define_constants();
$this->includes();
$this->dir = GMA_DIR;
$this->uri = GMA_URI;
$this->temp_dir = GMA_TEMP_DIR;
$this->temp_uri = GMA_TEMP_URL;
$this->stylesheet_dir = GMA_STYLESHEET_DIR;
$this->stylesheet_uri = GMA_STYLESHEET_URL;
$this->version = '1.0';
$this->load_plugin_textdomain();
// load posttype
new GMA_MenuManager();
$this->question = new GMA_Posts_Question();
$this->answer = new GMA_Posts_Answer();
$this->comment = new GMA_Posts_Comment();
$this->ajax = new GMA_Ajax();
$this->handle = new GMA_Handle();
$this->permission = new GMA_Permission();
$this->status = new GMA_Status();
$this->shortcode = new GMA_Shortcode();
$this->template = new GMA_Template();
$this->settings = new GMA_Settings();
$this->notifications = new GMA_Notifications();
$this->editor = new GMA_Editor();
$this->filter = new GMA_Filter();
$this->session = new GMA_Session();
$this->transient = new GMA_Transient();
$this->metaboxes = new GMA_Metaboxes();
$this->profile_visit = new GMA_DB_Profile_Visit();
$this->statistics = new GMA_DB_Statistics();
$this->utility = new GMA_Utility();
$this->system_status = new GMA_System_Status();
new GMA_AssetsLoader();
new GMA_Dashboard();
new GMA_Profile();
new GMA_Initializer();
new GMA_Comments();
new GMA_Addons();
new GMA_Schema();
new GMA_Feed();
register_activation_hook( __FILE__, array( $this, 'activate_hook' ) );
register_deactivation_hook( __FILE__, array( $this, 'deactivate_hook' ) );
}
/**
* Class implements singleton pattern,
* this method return an instance of class
*
* @since 1.0
* @access public
* @static
* @return Give_Me_Answer_Lite
*/
public static function instance() {
static $instance = null;
if ( is_null( $instance ) ) {
$instance = new self();
}
return $instance;
}
/**
* Includes necessary files()
*
* @since 1.0
* @access public
* @return void
*/
public function includes() {
require_once GMA_DIR . 'includes/class-autoload.php';
require_once GMA_DIR . 'includes/helper-functions.php';
require_once GMA_DIR . 'includes/class-ajax.php';
require_once GMA_DIR . 'includes/class-handle.php';
require_once GMA_DIR . 'includes/class-permission.php';
require_once GMA_DIR . 'includes/class-status.php';
require_once GMA_DIR . 'includes/class-shortcode.php';
require_once GMA_DIR . 'includes/class-template.php';
require_once GMA_DIR . 'includes/class-settings.php';
require_once GMA_DIR . 'includes/class-notifications.php';
require_once GMA_DIR . 'includes/class-filter.php';
require_once GMA_DIR . 'includes/class-session.php';
require_once GMA_DIR . 'includes/class-metaboxes.php';
require_once GMA_DIR . 'includes/class-browser-detection.php';
require_once GMA_DIR . 'includes/PostTypes/class-posts-base.php';
require_once GMA_DIR . 'includes/PostTypes/class-posts-answer.php';
require_once GMA_DIR . 'includes/PostTypes/class-posts-question.php';
require_once GMA_DIR . 'includes/PostTypes/class-posts-comment.php';
require_once GMA_DIR . 'includes/Widgets/class-widget-closed-questions.php';
require_once GMA_DIR . 'includes/Widgets/class-widget-latest-questions.php';
require_once GMA_DIR . 'includes/Widgets/class-widget-popular-questions.php';
require_once GMA_DIR . 'includes/Widgets/class-widget-question-tags.php';
require_once GMA_DIR . 'includes/Widgets/class-widget-related-questions.php';
require_once GMA_DIR . 'includes/Widgets/class-widget-top-questioners.php';
require_once GMA_DIR . 'includes/Widgets/class-widget-top-responders.php';
require_once GMA_DIR . 'includes/Widgets/class-widget-ask-question.php';
require_once GMA_DIR . 'includes/Widgets/class-widget-categories.php';
require_once GMA_DIR . 'includes/Widgets/class-widget-rss.php';
require_once GMA_DIR . 'includes/Database/class-db-base.php';
require_once GMA_DIR . 'includes/Database/class-db-profile-visit.php';
require_once GMA_DIR . 'includes/Database/class-db-statistics.php';
require_once GMA_DIR . 'includes/Libraries/feed/FeedWriter.php';
require_once GMA_DIR . 'includes/Libraries/Upload/class-upload.php';
require_once GMA_DIR . 'includes/Libraries/cmb2/init.php';
require_once GMA_DIR . 'includes/class-menu-manager.php';
require_once GMA_DIR . 'includes/class-user.php';
require_once GMA_DIR . 'includes/class-profile.php';
require_once GMA_DIR . 'includes/class-perpagemanager.php';
require_once GMA_DIR . 'includes/class-paginator.php';
require_once GMA_DIR . 'includes/class-assets-loader.php';
require_once GMA_DIR . 'includes/class-initializer.php';
require_once GMA_DIR . 'includes/class-transient.php';
require_once GMA_DIR . 'includes/class-editor.php';
require_once GMA_DIR . 'includes/class-dashboard.php';
require_once GMA_DIR . 'includes/class-comments.php';
require_once GMA_DIR . 'includes/class-addons.php';
require_once GMA_DIR . 'includes/class-utility.php';
require_once GMA_DIR . 'includes/class-schema.php';
require_once GMA_DIR . 'includes/class-system-status.php';
require_once GMA_DIR . 'includes/class-feed.php';
require_once GMA_DIR . 'includes/Tables/class-table-comments.php';
require_once GMA_DIR . 'includes/Tables/class-table-base.php';
require_once GMA_DIR . 'includes/Tables/class-table-user-questions.php';
require_once GMA_DIR . 'includes/Tables/class-table-user-answers.php';
require_once GMA_DIR . 'includes/Tables/class-table-favorite-questions.php';
require_once GMA_DIR . 'includes/Tables/class-table-answer.php';
}
/**
* Define constants
*
* @since 1.0
* @access public
* @return void
*/
public function define_constants() {
$defines = array(
'GMA_DIR' => plugin_dir_path( __FILE__ ),
'GMA_FILE' => __FILE__,
'GMA_URI' => plugin_dir_url( __FILE__ ),
'GMA_TEMP_DIR' => trailingslashit( get_template_directory() ),
'GMA_TEMP_URL' => trailingslashit( get_template_directory_uri() ),
'GMA_STYLESHEET_DIR' => trailingslashit( get_stylesheet_directory() ),
'GMA_STYLESHEET_URL' => trailingslashit( get_stylesheet_directory_uri() ),
'GMA_PREFIX' => 'gma_',
);
foreach( $defines as $k => $v ) {
if ( !defined( $k ) ) {
define( $k, $v );
}
}
}
// Update rewrite url when active plugin
public function activate_hook() {
$this->permission->prepare_permission_caps();
flush_rewrite_rules();
}
/**
* Deactivation hook
*
* @since 1.0
* @access public
* @return void
*/
public function deactivate_hook() {
$this->permission->remove_permision_caps();
wp_clear_scheduled_hook( 'gma_hourly_event' );
// Remove all transients
gma_lite()->transient->remove_all();
flush_rewrite_rules();
}
public function get_last_update() {
return $this->last_update;
}
/**
* Load plugin text domain, for localization
*
* @since 1.0
* @access private
* @return void
*/
private function load_plugin_textdomain() {
$locale = get_locale();
$mo = 'gma-' . $locale . '.mo';
load_textdomain( 'give-me-answer-lite', WP_LANG_DIR . '/give-me-answer-lite/' . $mo );
load_textdomain( 'give-me-answer-lite', plugin_dir_path( __FILE__ ) . 'languages/' . $mo );
load_plugin_textdomain( 'give-me-answer-lite' );
}
}
/**
* Get an instance of Give_Me_Answer class
* @since 1.0
* @return Give_Me_Answer_Lite
*/
function gma_lite() {
return Give_Me_Answer_Lite::instance();
}
$GLOBALS['gma'] = gma_lite();