-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimeapp.php
261 lines (214 loc) · 6.63 KB
/
timeapp.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
<?php
/**
* Plugin Name: TimeApp
* Plugin URI: http://ingroupconsulting.com/
* Description: Time Management's internal workflow tool
* Version: 2.2.3
* Author: Kiko Doran
* Author URI: http://ingroupconsulting.com/
* Text Domain: timeapp
*
* @package TimeApp
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'TimeApp' ) ) {
/**
* Main TimeApp class
*
* @since 1.0.0
*/
class TimeApp {
/**
* @var TimeApp $instance The one true TimeApp
* @since 1.0.0
*/
private static $instance;
/**
* @var object $template_tags The template tags object
* @since 2.0.0
*/
public $template_tags;
/**
* @var object $roles The TimeApp roles object
* @since 1.0.0
*/
public $roles;
/**
* @var object $settings The settings object
* @since 2.2.0
*/
public $settings;
/**
* @var bool $desktop Whether or not a desktop client is being used
* @since 2.2.0
*/
public $desktop;
/**
* Get active instance
*
* @access public
* @since 1.0.0
* @return self::$instance The one true TimeApp
*/
public static function instance() {
if ( ! self::$instance ) {
self::$instance = new TimeApp();
self::$instance->setup_constants();
if( ! class_exists( 'Browser' ) ) {
require_once TIMEAPP_DIR . 'includes/libraries/s214-settings/source/modules/sysinfo/browser.php';
}
$browser = new Browser();
$agent = $browser->getUserAgent();
self::$instance->desktop = ( stristr( $agent, 'Electron' ) ? true : false );
self::$instance->includes();
self::$instance->load_textdomain();
self::$instance->hooks();
self::$instance->template_tags = new TimeApp_Template_Tags();
self::$instance->roles = new TimeApp_Roles();
}
return self::$instance;
}
/**
* Throw error on object clone
*
* @access public
* @since 1.0.0
* @return void
*/
public function __clone() {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'timeapp' ), TIMEAPP_VER );
}
/**
* Disable unserializing of the class
*
* @access public
* @since 1.0.0
* @return void
*/
public function __wakeup() {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'timeapp' ), TIMEAPP_VER );
}
/**
* Setup plugin constants
*
* @access private
* @since 1.0.0
* @return void
*/
private function setup_constants() {
// Plugin version
define( 'TIMEAPP_VER', '2.2.3' );
// Plugin path
define( 'TIMEAPP_DIR', plugin_dir_path( __FILE__ ) );
// Plugin URL
define( 'TIMEAPP_URL', plugin_dir_url( __FILE__ ) );
// Plugin file
define( 'TIMEAPP_FILE', __FILE__ );
}
/**
* Include necessary files
*
* @access private
* @since 1.0.0
* @global array $timeapp_options The TimeApp options array
* @return void
*/
private function includes() {
global $timeapp_options;
require_once TIMEAPP_DIR . 'includes/admin/settings/register.php';
if ( ! class_exists( 'S214_Settings' ) ) {
require_once TIMEAPP_DIR . 'includes/libraries/s214-settings/source/class.s214-settings.php';
}
$this->settings = new S214_Settings( 'timeapp', 'general' );
$timeapp_options = $this->settings->get_settings();
require_once TIMEAPP_DIR . 'includes/functions.php';
require_once TIMEAPP_DIR . 'includes/scripts.php';
require_once TIMEAPP_DIR . 'includes/actions.php';
require_once TIMEAPP_DIR . 'includes/class.template-tags.php';
require_once TIMEAPP_DIR . 'includes/class.timeapp-roles.php';
if ( is_admin() ) {
require_once TIMEAPP_DIR . 'includes/class.textualizer.php';
require_once TIMEAPP_DIR . 'includes/post-types.php';
require_once TIMEAPP_DIR . 'includes/admin/actions.php';
require_once TIMEAPP_DIR . 'includes/admin/meta-boxes.php';
require_once TIMEAPP_DIR . 'includes/admin/admin-bar.php';
require_once TIMEAPP_DIR . 'includes/admin/dashboard/dashboard.php';
require_once TIMEAPP_DIR . 'includes/admin/bulk-actions.php';
require_once TIMEAPP_DIR . 'includes/admin/dashboard/dashboard-columns.php';
require_once TIMEAPP_DIR . 'includes/admin/dashboard/dashboard-widgets.php';
require_once TIMEAPP_DIR . 'includes/admin/notices.php';
require_once TIMEAPP_DIR . 'includes/install.php';
}
if ( $this->desktop ) {
require_once TIMEAPP_DIR . 'includes/desktop/pages.php';
}
if ( ! class_exists( 'InGroup_Plugin_Updater' ) ) {
require_once TIMEAPP_DIR . 'includes/libraries/InGroup_Plugin_Updater.php';
}
}
/**
* Run action and filter hooks
*
* @access private
* @since 1.0.0
* @return void
*/
private function hooks() {
if ( is_admin() && current_user_can( 'update_plugins' ) ) {
$license = get_option( 'timeapp_license', false );
if ( $license == 'valid' ) {
$update = new InGroup_Plugin_Updater( 'http://ingroupconsulting.com', __FILE__, array(
'version' => TIMEAPP_VER,
'license' => 'b76ae062e3cd62424479cafed2000529',
'item_id' => 622,
'author' => 'Kiko Doran'
) );
} else {
add_action( 'admin_init', 'timeapp_register_site' );
}
}
}
/**
* Internationalization
*
* @access public
* @since 1.0.0
* @return void
*/
public function load_textdomain() {
// Set filter for language directory
$lang_dir = dirname( plugin_basename( __FILE__ ) ) . '/languages/';
$lang_dir = apply_filters( 'timeapp_lang_dir', $lang_dir );
// Traditional WordPress plugin locale filter
$locale = apply_filters( 'plugin_locale', get_locale(), '' );
$mofile = sprintf( '%1$s-%2$s.mo', 'timeapp', $locale );
// Setup paths to current locale file
$mofile_local = $lang_dir . $mofile;
$mofile_global = WP_LANG_DIR . '/timeapp/' . $locale;
if ( file_exists( $mofile_global ) ) {
// Look in global /wp-content/languages/timeapp/ folder
load_textdomain( 'timeapp', $mofile_global );
} elseif ( file_exists( $mofile_local ) ) {
// Look in local /wp-content/plugins/timeapp/languages/ folder
load_textdomain( 'timeapp', $mofile_local );
} else {
// Load the default language files
load_plugin_textdomain( 'timeapp', false, $lang_dir );
}
}
}
}
/**
* The main function responsible for returning the one true TimeApp
* instance to functions everywhere.
*
* @since 1.0.0
* @return TimeApp The one true TimeApp instance
*/
function timeapp() {
return TimeApp::instance();
}
add_action( 'plugins_loaded', 'timeapp' );