-
Notifications
You must be signed in to change notification settings - Fork 0
/
software-issue-manager.php
363 lines (363 loc) · 13.5 KB
/
software-issue-manager.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
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
<?php
/**
* Plugin Name: Software Issue Manager
* Plugin URI: https://emdplugins.com
* Description: Software Issue Manager allows to track the resolution of every project issue in a productive and efficient way.
* Version: 4.8.2
* Author: eMarket Design
* Author URI: https://emarketdesign.com
* Text Domain: software-issue-manager
* Domain Path: /lang
* @package SOFTWARE_ISSUE_MANAGER
* @since WPAS 4.0
*/
/*
* LICENSE:
* Software Issue Manager 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
* any later version.
*
* Software Issue Manager 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.
*
* Please see <http://www.gnu.org/licenses/> for details.
*/
if (!defined('ABSPATH')) exit;
if (!class_exists('Software_Issue_Manager')):
/**
* Main class for Software Issue Manager
*
* @class Software_Issue_Manager
*/
final class Software_Issue_Manager {
/**
* @var Software_Issue_Manager single instance of the class
*/
private static $_instance;
public $textdomain = 'software-issue-manager';
public $app_name = 'software_issue_manager';
public $session;
/**
* Main Software_Issue_Manager Instance
*
* Ensures only one instance of Software_Issue_Manager is loaded or can be loaded.
*
* @static
* @see SOFTWARE_ISSUE_MANAGER()
* @return Software_Issue_Manager - Main instance
*/
public static function instance() {
if (!isset(self::$_instance)) {
self::$_instance = new self();
self::$_instance->define_constants();
self::$_instance->includes();
self::$_instance->load_plugin_textdomain();
self::$_instance->session = new Emd_Session('software_issue_manager');
add_filter('the_content', array(
self::$_instance,
'change_content'
));
add_action('admin_menu', array(
self::$_instance,
'display_settings'
));
add_filter('template_include', array(
self::$_instance,
'show_template'
));
add_action('widgets_init', array(
self::$_instance,
'include_widgets'
));
}
return self::$_instance;
}
/**
* Cloning is forbidden.
*/
public function __clone() {
_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', $this->textdomain) , '1.0');
}
/**
* Define Software_Issue_Manager Constants
*
* @access private
* @return void
*/
private function define_constants() {
define('SOFTWARE_ISSUE_MANAGER_VERSION', '4.8.2');
define('SOFTWARE_ISSUE_MANAGER_AUTHOR', 'eMarket Design');
define('SOFTWARE_ISSUE_MANAGER_NAME', 'Software Issue Manager');
define('SOFTWARE_ISSUE_MANAGER_PLUGIN_FILE', __FILE__);
define('SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('SOFTWARE_ISSUE_MANAGER_PLUGIN_URL', plugin_dir_url(__FILE__));
define('EMD_ADMIN_DIR', ABSPATH . 'wp-admin');
}
/**
* Include required files
*
* @access private
* @return void
*/
private function includes() {
//these files are in all apps
if (!function_exists('emd_mb_meta')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'assets/ext/emd-meta-box/emd-meta-box.php';
}
if (!function_exists('emd_translate_date_format')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/date-functions.php';
}
if (!function_exists('emd_get_hidden_func')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/common-functions.php';
}
if (!class_exists('Emd_Entity')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/entities/class-emd-entity.php';
}
if (!function_exists('emd_get_template_part')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/layout-functions.php';
}
//the rest
if (!class_exists('Emd_Query')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/class-emd-query.php';
}
if (!function_exists('emd_get_p2p_connections')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/relationship-functions.php';
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'assets/ext/posts-to-posts/posts-to-posts.php';
}
if (!function_exists('emd_shc_get_layout_list')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/shortcode-functions.php';
}
if (!class_exists('Emd_Widget')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/class-emd-widget.php';
}
if (!class_exists('Emd_Session')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/class-emd-session.php';
}
if (!function_exists('emd_show_login_register_forms')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/login-register-functions.php';
}
do_action('emd_ext_include_files');
//app specific files
if (!function_exists('emd_show_settings_page')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/admin/settings-functions.php';
}
if (!function_exists('emd_misc_register_settings')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/admin/settings-functions-misc.php';
}
if (is_admin()) {
if (!class_exists('WP_List_Table', false)) {
require_once EMD_ADMIN_DIR . '/includes/class-wp-list-table.php';
}
if (!class_exists('Emd_List_Table')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/admin/class-emd-list-table.php';
}
//these files are in all apps
if (!function_exists('emd_display_store')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/admin/store-functions.php';
}
//the rest
if (!function_exists('emd_shc_button')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/admin/wpas-btn-functions.php';
}
if (!class_exists('Emd_Single_Taxonomy')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/admin/singletax/class-emd-single-taxonomy.php';
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/admin/singletax/emd-singletax-functions.php';
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/admin/singletax/class-emd-walker-radio.php';
}
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/admin/glossary.php';
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/admin/getting-started.php';
}
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/class-install-deactivate.php';
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/entities/class-emd-issue.php';
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/entities/class-emd-project.php';
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/entities/emd-issue-shortcodes.php';
if (!function_exists('emd_show_forms_lite_page')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/emd-form-builder-lite/emd-form-builder.php';
}
if (!function_exists('emd_lite_modal')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/emd-lite/emd-lite.php';
}
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/scripts.php';
if (!function_exists('emd_limit_by')) {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/filter-functions.php';
}
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/query-filters.php';
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/plugin-feedback-functions.php';
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/content-functions.php';
}
/**
* Loads plugin language files
*
* @access public
* @return void
*/
public function load_plugin_textdomain() {
$locale = apply_filters('plugin_locale', get_locale() , 'software-issue-manager');
$mofile = sprintf('%1$s-%2$s.mo', 'software-issue-manager', $locale);
$mofile_shared = sprintf('%1$s-emd-plugins-%2$s.mo', 'software-issue-manager', $locale);
$lang_file_list = Array(
'emd-plugins' => $mofile_shared,
'software-issue-manager' => $mofile
);
foreach ($lang_file_list as $lang_key => $lang_file) {
$localmo = SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . '/lang/' . $lang_file;
$globalmo = WP_LANG_DIR . '/software-issue-manager/' . $lang_file;
if (file_exists($globalmo)) {
load_textdomain($lang_key, $globalmo);
} elseif (file_exists($localmo)) {
load_textdomain($lang_key, $localmo);
} else {
load_plugin_textdomain($lang_key, false, SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . '/lang/');
}
}
}
/**
* Changes content on frontend views
*
* @access public
* @param string $content
*
* @return string $content
*/
public function change_content($content) {
if (!is_admin()) {
if (post_password_required()) {
$content = get_the_password_form();
} else {
$mypost_type = get_post_type();
if ($mypost_type == 'post' || $mypost_type == 'page') {
$mypost_type = "emd_" . $mypost_type;
}
$ent_list = get_option($this->app_name . '_ent_list');
if (in_array($mypost_type, array_keys($ent_list)) && class_exists($mypost_type)) {
$func = "change_content";
$obj = new $mypost_type;
$content = $obj->$func($content);
}
}
}
return $content;
}
/**
* Creates plugin page in menu with submenus
*
* @access public
* @return void
*/
public function display_settings() {
$settings_pages_cap = 'manage_options';
$settings_pages_cap = apply_filters('emd_settings_pages_cap', $settings_pages_cap, $this->app_name);
add_menu_page(__('SIM Com', $this->textdomain) , __('SIM Com', $this->textdomain) , $settings_pages_cap, $this->app_name, array(
$this,
'display_getting_started_page'
));
add_submenu_page($this->app_name, __('Getting Started', $this->textdomain) , __('Getting Started', $this->textdomain) , $settings_pages_cap, $this->app_name);
add_submenu_page($this->app_name, __('Glossary', $this->textdomain) , __('Glossary', $this->textdomain) , $settings_pages_cap, $this->app_name . '_glossary', array(
$this,
'display_glossary_page'
));
add_submenu_page($this->app_name, __('Settings', $this->textdomain) , __('Settings', $this->textdomain) , $settings_pages_cap, $this->app_name . '_settings', array(
$this,
'display_settings_page'
));
add_submenu_page($this->app_name, __('Forms', $this->textdomain) , __('Forms', $this->textdomain) , $settings_pages_cap, $this->app_name . '_forms', array(
$this,
'display_forms_page'
));
add_submenu_page($this->app_name, __('Custom Fields', $this->textdomain) , __('Custom Fields', $this->textdomain) , $settings_pages_cap, $this->app_name . '_cust_fields', array(
$this,
'display_cust_fields_page'
));
add_submenu_page($this->app_name, __('Plugins', $this->textdomain) , __('Plugins', $this->textdomain) , $settings_pages_cap, $this->app_name . '_store', array(
$this,
'display_store_page'
));
add_submenu_page($this->app_name, __('Support', $this->textdomain) , __('Support', $this->textdomain) , $settings_pages_cap, $this->app_name . '_support', array(
$this,
'display_support_page'
));
//add submenu page under app settings page
do_action('emd_ext_add_menu_pages', $this->app_name);
$emd_lic_settings = get_option('emd_license_settings', Array());
$show_lic_page = 0;
if (!empty($emd_lic_settings)) {
foreach ($emd_lic_settings as $key => $val) {
if ($key == $this->app_name) {
$show_lic_page = 1;
break;
} else if ($val['type'] == 'ext') {
$show_lic_page = 1;
break;
}
}
if ($show_lic_page == 1 && function_exists('emd_show_license_page')) {
add_submenu_page($this->app_name, __('Licenses', $this->textdomain) , __('Licenses', $this->textdomain) , 'manage_options', $this->app_name . '_licenses', array(
$this,
'display_licenses_page'
));
}
}
}
/**
* Calls settings function to display glossary page
*
* @access public
* @return void
*/
public function display_glossary_page() {
do_action($this->app_name . '_settings_glossary');
}
public function display_getting_started_page() {
do_action($this->app_name . '_getting_started');
}
public function display_store_page() {
emd_display_store($this->textdomain);
}
public function display_support_page() {
emd_display_support($this->textdomain, 2, 'software-issue-manager');
}
public function display_licenses_page() {
do_action('emd_show_license_page', $this->app_name);
}
public function display_settings_page() {
do_action('emd_show_settings_page', $this->app_name);
}
public function display_forms_page() {
do_action('emd_show_forms_lite_page', $this->app_name);
}
public function display_cust_fields_page() {
emd_lite_get_operations('cust_fields', __('Custom Fields', $this->textdomain) , $this->textdomain);
}
/**
* Displays single, archive, tax and no-access frontend views
*
* @access public
* @return string, $template:emd template or template
*/
public function show_template($template) {
return emd_show_template($this->app_name, SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR, $template);
}
/**
* Loads sidebar widgets
*
* @access public
* @return void
*/
public function include_widgets() {
require_once SOFTWARE_ISSUE_MANAGER_PLUGIN_DIR . 'includes/entities/class-emd-issue-widgets.php';
}
}
endif;
/**
* Returns the main instance of Software_Issue_Manager
*
* @return Software_Issue_Manager
*/
function SOFTWARE_ISSUE_MANAGER() {
return Software_Issue_Manager::instance();
}
// Get the Software_Issue_Manager instance
SOFTWARE_ISSUE_MANAGER();