-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtask-breaker.php
222 lines (159 loc) · 5.19 KB
/
task-breaker.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
<?php
/**
* Plugin Name: TaskBreaker - Group Project Management
* Description: A simple WordPress plugin for managing projects and tasks. Integrated into BuddyPress Groups for best collaborative experience.
* Version: 1.5.1
* Author: Dunhakdis
* Author URI: http://dunhakdis.com/
* Text Domain: taskbreaker-project-management
* Domain Path: /languages
* License: GPL2
*
* PHP version 5.6+
*
* @category Loaders
* @package TaskBreaker
* @author DUNHAKDIS <[email protected]>
* @license https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html GPL2
* @link <http://dunhakdis.com>
* @since 1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
return;
}
define( 'TASK_BREAKER_PROFILER', false );
define( 'TASK_BREAKER_VERSION', '1.5.1' );
define( 'TASK_BREAKER_PROJECT_LIMIT', 10 );
define( 'TASK_BREAKER_PROJECT_SLUG', apply_filters('TASK_BREAKER_PROJECT_SLUG', 'project') );
define( 'TASK_BREAKER_ASSET_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
define( 'TASKBREAKER_DIRECTORY_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
// Setup the tables on activation.
register_activation_hook( __FILE__, 'task_breaker_install' );
// Plugin l10n.
add_action( 'plugins_loaded', 'task_breaker_localize_plugin' );
// Include taskbreaker projects transactions.
add_action( 'init', 'task_breaker_register_transactions' );
// Include taskbreaker projects component.
add_action( 'bp_loaded', 'task_breaker_register_projects_component' );
// Included other taskbreaker components.
add_action( 'bp_loaded', 'task_breaker_load_components' );
// Check if group is active
add_action( 'bp_loaded', 'taskbreaker_is_group_active' );
/**
* Do not run TaskBreaker on PHP version 5.3.0-
*/
if ( version_compare( PHP_VERSION, '5.3.0', '<' ) ) {
add_action( 'admin_notices', 'taskbreaker_admin_notice' );
function taskbreaker_admin_notice() {
?>
<div class="notice notice-error is-dismissible">
<p><strong><?php _e( 'Notice: TaskBreaker is only available for PHP Version 5.4.0 and above.', ' taskbreaker-project-management' ); ?></strong></p>
</div>
<?php }
}
function taskbreaker_is_group_active() {
if ( function_exists( 'bp_is_active' ) ) {
if ( ! bp_is_active( 'groups' ) ) {
add_action( 'admin_notices', 'taskbreaker_admin_notice_group_required' );
}
}
}
function taskbreaker_admin_notice_group_required() {
?>
<div class="notice notice-warning is-dismissible">
<p><strong><?php _e( 'Notice: TaskBreaker requires BuddyPress Groups Component to be enabled.', ' taskbreaker-project-management' ); ?></strong></p>
</div>
<?php }
// Require the assets needed.
require_once plugin_dir_path( __FILE__ ) . 'core/enqueue.php';
// Require the script that registers our 'Project' post type.
require_once plugin_dir_path( __FILE__ ) . 'includes/project-post-type.php';
// Require install script.
require_once plugin_dir_path( __FILE__ ) . 'install/table.php';
// Require notification file.
require_once plugin_dir_path( __FILE__ ) . 'includes/project-notifications.php';
// Require widgets file.
require_once plugin_dir_path( __FILE__ ) . 'widgets/widgets.php';
// Require file attachments class.
require_once plugin_dir_path( __FILE__ ) . 'core/file-attachments.php';
// Require the template tags.
include_once plugin_dir_path( __FILE__ ) . 'core/template-tags.php';
// Register all the action hooks
include_once plugin_dir_path( __FILE__ ) . 'actions/actions.php';
/**
* TaskBreaker l10n callback.
*
* @return void
*/
function task_breaker_localize_plugin() {
$rel_path = basename( dirname( __FILE__ ) ) . '/languages';
load_plugin_textdomain( 'taskbreaker-project-management', false, $rel_path );
return;
}
/**
* Register our middle man API transactions.
*
* @return void
*/
function task_breaker_register_transactions() {
include_once plugin_dir_path( __FILE__ ) . 'transactions/controller.php';
return;
}
/**
* Register our project components.
*
* @return void
*/
function task_breaker_register_projects_component() {
// Include Task Breaker Project Component.
include_once plugin_dir_path( __FILE__ ) . '/includes/project-component.php';
// Include Task Breaker Project Group Component.
include_once plugin_dir_path( __FILE__ ) . '/includes/project-group-component.php';
return;
}
/**
* Load TaskBreaker email templates and callbacks for BuddyPress Email API.
*
* @return void
*/
function task_breaker_load_components() {
// Require our email handler class.
include_once plugin_dir_path( __FILE__ ) . 'emails/class-buddypress-mail-register.php';
return;
}
/**
* A flat class to prevent calls to WordPress globals
*
* @version 1.3.6
*/
class TaskBreaker {
/**
* PHP Die Wrapper.
*
* @return void
*/
public static function stop( $message ) {
die( $message );
}
public static function wpdb() {
global $wpdb;
return $wpdb;
}
public static function bp_core_get_table_prefix() {
$prefix = '';
if ( function_exists( 'bp_core_get_table_prefix' ) ) {
$prefix = bp_core_get_table_prefix();
} else {
return;
}
return $prefix;
}
public static function get_post() {
global $post;
return $post;
}
public static function wpfilesystem() {
global $wp_filesystem;
return $wp_filesystem;
}
}