PluginProbe ʕ •ᴥ•ʔ
LatePoint – Calendar Booking Plugin for Appointments and Events / 5.3.1
LatePoint – Calendar Booking Plugin for Appointments and Events v5.3.1
5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.1.91 5.1.92 5.1.93 5.1.94 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1
latepoint / latepoint.php
latepoint Last commit date
blocks 4 months ago languages 9 months ago lib 3 months ago public 3 months ago latepoint.php 3 months ago readme.txt 3 months ago uninstall.php 4 months ago
latepoint.php
1613 lines
1 <?php
2 /**
3 * Plugin Name: LatePoint
4 * Description: Appointment Scheduling Software for WordPress
5 * Version: 5.3.1
6 * Author: LatePoint
7 * Author URI: https://latepoint.com
8 * Plugin URI: https://latepoint.com
9 * Text Domain: latepoint
10 * Domain Path: /languages
11 * License: GPLv3
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly.
16 }
17
18
19 if ( ! class_exists( 'LatePoint' ) ) :
20
21 /**
22 * Main LatePoint Class.
23 *
24 */
25
26 final class LatePoint {
27
28 /**
29 * LatePoint version.
30 *
31 */
32 public $version = '5.3.1';
33 public $db_version = '2.3.0';
34
35
36 /**
37 * LatePoint Constructor.
38 */
39 public function __construct() {
40
41 $this->define_constants();
42 $this->includes();
43 $this->init_hooks();
44 OsDatabaseHelper::check_db_version();
45 OsDatabaseHelper::check_db_version_for_addons();
46
47
48 $GLOBALS['latepoint_settings'] = new OsSettingsHelper();
49 }
50
51
52 /**
53 * Define constant if not already set.
54 *
55 */
56 public function define( $name, $value ) {
57 if ( ! defined( $name ) ) {
58 define( $name, $value );
59 }
60 }
61
62
63 /**
64 * Get the plugin url. *has trailing slash
65 * @return string
66 */
67 public static function plugin_url() {
68 return plugin_dir_url( __FILE__ );
69 }
70
71 public static function public_javascripts() {
72 return plugin_dir_url( __FILE__ ) . 'public/javascripts/';
73 }
74
75 public static function public_vendor_javascripts() {
76 return plugin_dir_url( __FILE__ ) . 'public/javascripts/vendor/';
77 }
78
79 public static function public_stylesheets() {
80 return plugin_dir_url( __FILE__ ) . 'public/stylesheets/';
81 }
82
83 public static function blocks_build_url() {
84 return plugin_dir_url( __FILE__ ) . 'blocks/build/';
85 }
86
87 public static function node_modules_url() {
88 return plugin_dir_url( __FILE__ ) . 'node_modules/';
89 }
90
91 public static function vendor_assets_url() {
92 return plugin_dir_url( __FILE__ ) . 'vendor/';
93 }
94
95 public static function images_url() {
96 return plugin_dir_url( __FILE__ ) . 'public/images/';
97 }
98
99 /**
100 * Get the plugin path.
101 * @return string
102 */
103 public static function plugin_path() {
104 return plugin_dir_path( __FILE__ );
105 }
106
107
108 /**
109 * Define LatePoint Constants.
110 */
111 public function define_constants() {
112 $upload_dir = wp_upload_dir();
113
114 // ENVIRONMENTS TYPES
115 if ( ! defined( 'LATEPOINT_ENV_LIVE' ) ) {
116 define( 'LATEPOINT_ENV_LIVE', 'live' );
117 }
118 if ( ! defined( 'LATEPOINT_ENV_DEMO' ) ) {
119 define( 'LATEPOINT_ENV_DEMO', 'demo' );
120 }
121 if ( ! defined( 'LATEPOINT_ENV_DEV' ) ) {
122 define( 'LATEPOINT_ENV_DEV', 'dev' );
123 }
124
125 // PAYMENT ENVIRONMENTS TYPES
126 if ( ! defined( 'LATEPOINT_PAYMENTS_ENV_LIVE' ) ) {
127 define( 'LATEPOINT_PAYMENTS_ENV_LIVE', 'live' );
128 }
129 if ( ! defined( 'LATEPOINT_PAYMENTS_ENV_DEMO' ) ) {
130 define( 'LATEPOINT_PAYMENTS_ENV_DEMO', 'demo' );
131 }
132 if ( ! defined( 'LATEPOINT_PAYMENTS_ENV_DEV' ) ) {
133 define( 'LATEPOINT_PAYMENTS_ENV_DEV', 'dev' );
134 }
135
136
137 if ( ! defined( 'LATEPOINT_PAYMENTS_DEV_SUFFIX' ) ) {
138 define( 'LATEPOINT_PAYMENTS_DEV_SUFFIX', '_dev' );
139 }
140
141 if ( ! defined( 'LATEPOINT_ENV' ) ) {
142 define( 'LATEPOINT_ENV', LATEPOINT_ENV_LIVE );
143 }
144 if ( ! defined( 'LATEPOINT_ALLOW_LOCAL_SERVER' ) ) {
145 define( 'LATEPOINT_ALLOW_LOCAL_SERVER', true );
146 }
147
148 if ( ! defined( 'LATEPOINT_ALLOW_SMS' ) ) {
149 define( 'LATEPOINT_ALLOW_SMS', true );
150 }
151 if ( ! defined( 'LATEPOINT_ALLOW_WHATSAPP' ) ) {
152 define( 'LATEPOINT_ALLOW_WHATSAPP', true );
153 }
154 if ( ! defined( 'LATEPOINT_ALLOW_EMAILS' ) ) {
155 define( 'LATEPOINT_ALLOW_EMAILS', true );
156 }
157
158 if ( ! defined( 'LATEPOINT_PLUGIN_FILE' ) ) {
159 define( 'LATEPOINT_PLUGIN_FILE', __FILE__ );
160 }
161 if ( ! defined( 'LATEPOINT_STYLESHEETS_URL' ) ) {
162 define( 'LATEPOINT_STYLESHEETS_URL', $this->public_stylesheets() );
163 }
164 if ( ! defined( 'LATEPOINT_BLOCKS_BUILD_URL' ) ) {
165 define( 'LATEPOINT_BLOCKS_BUILD_URL', $this->blocks_build_url() );
166 }
167 if ( ! defined( 'LATEPOINT_ABSPATH' ) ) {
168 define( 'LATEPOINT_ABSPATH', dirname( __FILE__ ) . '/' );
169 }
170 if ( ! defined( 'LATEPOINT_LIB_ABSPATH' ) ) {
171 define( 'LATEPOINT_LIB_ABSPATH', LATEPOINT_ABSPATH . 'lib/' );
172 }
173 if ( ! defined( 'LATEPOINT_CONFIG_ABSPATH' ) ) {
174 define( 'LATEPOINT_CONFIG_ABSPATH', LATEPOINT_LIB_ABSPATH . 'config/' );
175 }
176 if ( ! defined( 'LATEPOINT_BLOCKS_ABSPATH' ) ) {
177 define( 'LATEPOINT_BLOCKS_ABSPATH', LATEPOINT_ABSPATH . 'blocks/build/' );
178 }
179 if ( ! defined( 'LATEPOINT_BOWER_ABSPATH' ) ) {
180 define( 'LATEPOINT_BOWER_ABSPATH', LATEPOINT_ABSPATH . 'vendor/bower_components/' );
181 }
182 if ( ! defined( 'LATEPOINT_VIEWS_ABSPATH' ) ) {
183 define( 'LATEPOINT_VIEWS_ABSPATH', LATEPOINT_LIB_ABSPATH . 'views/' );
184 }
185 if ( ! defined( 'LATEPOINT_VIEWS_ABSPATH_SHARED' ) ) {
186 define( 'LATEPOINT_VIEWS_ABSPATH_SHARED', LATEPOINT_LIB_ABSPATH . 'views/shared/' );
187 }
188 if ( ! defined( 'LATEPOINT_VIEWS_MAILERS_ABSPATH' ) ) {
189 define( 'LATEPOINT_VIEWS_MAILERS_ABSPATH', LATEPOINT_VIEWS_ABSPATH . 'mailers/' );
190 }
191 if ( ! defined( 'LATEPOINT_VIEWS_LAYOUTS_ABSPATH' ) ) {
192 define( 'LATEPOINT_VIEWS_LAYOUTS_ABSPATH', LATEPOINT_VIEWS_ABSPATH . 'layouts/' );
193 }
194 if ( ! defined( 'LATEPOINT_VIEWS_PARTIALS_ABSPATH' ) ) {
195 define( 'LATEPOINT_VIEWS_PARTIALS_ABSPATH', LATEPOINT_VIEWS_ABSPATH . 'partials/' );
196 }
197 if ( ! defined( 'LATEPOINT_PLUGIN_BASENAME' ) ) {
198 define( 'LATEPOINT_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
199 }
200
201 if ( ! defined( 'LATEPOINT_PLUGIN_URL' ) ) {
202 define( 'LATEPOINT_PLUGIN_URL', $this->plugin_url() );
203 }
204 if ( ! defined( 'LATEPOINT_LIB_URL' ) ) {
205 define( 'LATEPOINT_LIB_URL', LATEPOINT_PLUGIN_URL . 'lib/' );
206 }
207 if ( ! defined( 'LATEPOINT_PUBLIC_URL' ) ) {
208 define( 'LATEPOINT_PUBLIC_URL', LATEPOINT_PLUGIN_URL . 'public/' );
209 }
210 if ( ! defined( 'LATEPOINT_IMAGES_URL' ) ) {
211 define( 'LATEPOINT_IMAGES_URL', LATEPOINT_PUBLIC_URL . 'images/' );
212 }
213 if ( ! defined( 'LATEPOINT_DEFAULT_AVATAR_URL' ) ) {
214 define( 'LATEPOINT_DEFAULT_AVATAR_URL', LATEPOINT_IMAGES_URL . 'default-avatar.jpg' );
215 }
216 if ( ! defined( 'LATEPOINT_MARKETPLACE' ) ) {
217 define( 'LATEPOINT_MARKETPLACE', 'codecanyon' );
218 }
219 // role to assigne WP user to so they are connected to a LatePoint backend user type (agent or manager)
220 if ( ! defined( 'LATEPOINT_WP_ADMIN_ROLE' ) ) {
221 define( 'LATEPOINT_WP_ADMIN_ROLE', 'administrator' );
222 }
223 if ( ! defined( 'LATEPOINT_WP_AGENT_ROLE' ) ) {
224 define( 'LATEPOINT_WP_AGENT_ROLE', 'latepoint_agent' );
225 }
226 if ( ! defined( 'LATEPOINT_WP_MANAGER_ROLE' ) ) {
227 define( 'LATEPOINT_WP_MANAGER_ROLE', 'latepoint_manager' );
228 }
229 if ( ! defined( 'LATEPOINT_WP_CUSTOMER_ROLE' ) ) {
230 define( 'LATEPOINT_WP_CUSTOMER_ROLE', 'latepoint_customer' );
231 }
232
233 if ( ! defined( 'LATEPOINT_USER_TYPE_ADMIN' ) ) {
234 define( 'LATEPOINT_USER_TYPE_ADMIN', 'admin' );
235 }
236 if ( ! defined( 'LATEPOINT_USER_TYPE_AGENT' ) ) {
237 define( 'LATEPOINT_USER_TYPE_AGENT', 'agent' );
238 }
239 if ( ! defined( 'LATEPOINT_USER_TYPE_CUSTOM' ) ) {
240 define( 'LATEPOINT_USER_TYPE_CUSTOM', 'custom' );
241 }
242 if ( ! defined( 'LATEPOINT_USER_TYPE_CUSTOMER' ) ) {
243 define( 'LATEPOINT_USER_TYPE_CUSTOMER', 'customer' );
244 }
245
246 if ( ! defined( 'LATEPOINT_PARAMS_SCOPE_PUBLIC' ) ) {
247 define( 'LATEPOINT_PARAMS_SCOPE_PUBLIC', 'public' );
248 }
249 if ( ! defined( 'LATEPOINT_PARAMS_SCOPE_ADMIN' ) ) {
250 define( 'LATEPOINT_PARAMS_SCOPE_ADMIN', 'admin' );
251 }
252 if ( ! defined( 'LATEPOINT_PARAMS_SCOPE_CUSTOMER' ) ) {
253 define( 'LATEPOINT_PARAMS_SCOPE_CUSTOMER', 'customer' );
254 }
255
256
257 if ( ! defined( 'LATEPOINT_VERSION' ) ) {
258 define( 'LATEPOINT_VERSION', $this->version );
259 }
260 if ( ! defined( 'LATEPOINT_MIN_REQUIRED_PRO_VERSION' ) ) {
261 define( 'LATEPOINT_MIN_REQUIRED_PRO_VERSION', '1.2.5' );
262 }
263 if ( ! defined( 'LATEPOINT_ENCRYPTION_KEY' ) ) {
264 define( 'LATEPOINT_ENCRYPTION_KEY', 'oiaf(*Ufdsoh2ie7QEy,R@6(I9H/VoX^r4}SHC_7W-<$S!,/kd)OSw?.Y9lcd105cu$' );
265 }
266
267 if ( ! defined( 'LATEPOINT_AGENT_POST_TYPE' ) ) {
268 define( 'LATEPOINT_AGENT_POST_TYPE', 'latepoint_agent' );
269 }
270
271 if ( ! defined( 'LATEPOINT_UPGRADE_URL' ) ) {
272 define( 'LATEPOINT_UPGRADE_URL', 'https://latepoint.com/upgrade-from-wp' );
273 }
274 if ( ! defined( 'LATEPOINT_SERVICE_POST_TYPE' ) ) {
275 define( 'LATEPOINT_SERVICE_POST_TYPE', 'latepoint_service' );
276 }
277 if ( ! defined( 'LATEPOINT_CUSTOMER_POST_TYPE' ) ) {
278 define( 'LATEPOINT_CUSTOMER_POST_TYPE', 'latepoint_customer' );
279 }
280
281 if ( ! defined( 'LATEPOINT_DB_VERSION' ) ) {
282 define( 'LATEPOINT_DB_VERSION', $this->db_version );
283 }
284
285 global $wpdb;
286 if ( ! defined( 'LATEPOINT_TABLE_RECURRENCES' ) ) {
287 define( 'LATEPOINT_TABLE_RECURRENCES', $wpdb->prefix . 'latepoint_recurrences' );
288 }
289 if ( ! defined( 'LATEPOINT_TABLE_BUNDLES' ) ) {
290 define( 'LATEPOINT_TABLE_BUNDLES', $wpdb->prefix . 'latepoint_bundles' );
291 }
292 if ( ! defined( 'LATEPOINT_TABLE_BUNDLES_SERVICES' ) ) {
293 define( 'LATEPOINT_TABLE_JOIN_BUNDLES_SERVICES', $wpdb->prefix . 'latepoint_bundles_services' );
294 }
295 if ( ! defined( 'LATEPOINT_TABLE_BOOKINGS' ) ) {
296 define( 'LATEPOINT_TABLE_BOOKINGS', $wpdb->prefix . 'latepoint_bookings' );
297 }
298 if ( ! defined( 'LATEPOINT_TABLE_SESSIONS' ) ) {
299 define( 'LATEPOINT_TABLE_SESSIONS', $wpdb->prefix . 'latepoint_sessions' );
300 }
301 if ( ! defined( 'LATEPOINT_TABLE_SERVICES' ) ) {
302 define( 'LATEPOINT_TABLE_SERVICES', $wpdb->prefix . 'latepoint_services' );
303 }
304 if ( ! defined( 'LATEPOINT_TABLE_SETTINGS' ) ) {
305 define( 'LATEPOINT_TABLE_SETTINGS', $wpdb->prefix . 'latepoint_settings' );
306 }
307 if ( ! defined( 'LATEPOINT_TABLE_SERVICE_CATEGORIES' ) ) {
308 define( 'LATEPOINT_TABLE_SERVICE_CATEGORIES', $wpdb->prefix . 'latepoint_service_categories' );
309 }
310 if ( ! defined( 'LATEPOINT_TABLE_WORK_PERIODS' ) ) {
311 define( 'LATEPOINT_TABLE_WORK_PERIODS', $wpdb->prefix . 'latepoint_work_periods' );
312 }
313 if ( ! defined( 'LATEPOINT_TABLE_CUSTOM_PRICES' ) ) {
314 define( 'LATEPOINT_TABLE_CUSTOM_PRICES', $wpdb->prefix . 'latepoint_custom_prices' );
315 }
316 if ( ! defined( 'LATEPOINT_TABLE_AGENTS_SERVICES' ) ) {
317 define( 'LATEPOINT_TABLE_AGENTS_SERVICES', $wpdb->prefix . 'latepoint_agents_services' );
318 }
319 if ( ! defined( 'LATEPOINT_TABLE_ACTIVITIES' ) ) {
320 define( 'LATEPOINT_TABLE_ACTIVITIES', $wpdb->prefix . 'latepoint_activities' );
321 }
322 if ( ! defined( 'LATEPOINT_TABLE_TRANSACTIONS' ) ) {
323 define( 'LATEPOINT_TABLE_TRANSACTIONS', $wpdb->prefix . 'latepoint_transactions' );
324 }
325 if ( ! defined( 'LATEPOINT_TABLE_TRANSACTION_REFUNDS' ) ) {
326 define( 'LATEPOINT_TABLE_TRANSACTION_REFUNDS', $wpdb->prefix . 'latepoint_transaction_refunds' );
327 }
328 if ( ! defined( 'LATEPOINT_TABLE_TRANSACTION_INTENTS' ) ) {
329 define( 'LATEPOINT_TABLE_TRANSACTION_INTENTS', $wpdb->prefix . 'latepoint_transaction_intents' );
330 }
331 if ( ! defined( 'LATEPOINT_TABLE_AGENTS' ) ) {
332 define( 'LATEPOINT_TABLE_AGENTS', $wpdb->prefix . 'latepoint_agents' );
333 }
334 if ( ! defined( 'LATEPOINT_TABLE_CUSTOMERS' ) ) {
335 define( 'LATEPOINT_TABLE_CUSTOMERS', $wpdb->prefix . 'latepoint_customers' );
336 }
337 if ( ! defined( 'LATEPOINT_TABLE_CUSTOMER_META' ) ) {
338 define( 'LATEPOINT_TABLE_CUSTOMER_META', $wpdb->prefix . 'latepoint_customer_meta' );
339 }
340 if ( ! defined( 'LATEPOINT_TABLE_SERVICE_META' ) ) {
341 define( 'LATEPOINT_TABLE_SERVICE_META', $wpdb->prefix . 'latepoint_service_meta' );
342 }
343 if ( ! defined( 'LATEPOINT_TABLE_BOOKING_META' ) ) {
344 define( 'LATEPOINT_TABLE_BOOKING_META', $wpdb->prefix . 'latepoint_booking_meta' );
345 }
346 if ( ! defined( 'LATEPOINT_TABLE_AGENT_META' ) ) {
347 define( 'LATEPOINT_TABLE_AGENT_META', $wpdb->prefix . 'latepoint_agent_meta' );
348 }
349 if ( ! defined( 'LATEPOINT_TABLE_BUNDLE_META' ) ) {
350 define( 'LATEPOINT_TABLE_BUNDLE_META', $wpdb->prefix . 'latepoint_bundle_meta' );
351 }
352 if ( ! defined( 'LATEPOINT_TABLE_STEPS' ) ) {
353 define( 'LATEPOINT_TABLE_STEPS', $wpdb->prefix . 'latepoint_steps' );
354 }
355 if ( ! defined( 'LATEPOINT_TABLE_STEP_SETTINGS' ) ) {
356 define( 'LATEPOINT_TABLE_STEP_SETTINGS', $wpdb->prefix . 'latepoint_step_settings' );
357 }
358 if ( ! defined( 'LATEPOINT_TABLE_LOCATIONS' ) ) {
359 define( 'LATEPOINT_TABLE_LOCATIONS', $wpdb->prefix . 'latepoint_locations' );
360 }
361 if ( ! defined( 'LATEPOINT_TABLE_LOCATION_CATEGORIES' ) ) {
362 define( 'LATEPOINT_TABLE_LOCATION_CATEGORIES', $wpdb->prefix . 'latepoint_location_categories' );
363 }
364 if ( ! defined( 'LATEPOINT_TABLE_PROCESSES' ) ) {
365 define( 'LATEPOINT_TABLE_PROCESSES', $wpdb->prefix . 'latepoint_processes' );
366 }
367 if ( ! defined( 'LATEPOINT_TABLE_PROCESS_JOBS' ) ) {
368 define( 'LATEPOINT_TABLE_PROCESS_JOBS', $wpdb->prefix . 'latepoint_process_jobs' );
369 }
370
371 if ( ! defined( 'LATEPOINT_TABLE_CARTS' ) ) {
372 define( 'LATEPOINT_TABLE_CARTS', $wpdb->prefix . 'latepoint_carts' );
373 }
374 if ( ! defined( 'LATEPOINT_TABLE_CART_META' ) ) {
375 define( 'LATEPOINT_TABLE_CART_META', $wpdb->prefix . 'latepoint_cart_meta' );
376 }
377 if ( ! defined( 'LATEPOINT_TABLE_CART_ITEMS' ) ) {
378 define( 'LATEPOINT_TABLE_CART_ITEMS', $wpdb->prefix . 'latepoint_cart_items' );
379 }
380
381 if ( ! defined( 'LATEPOINT_TABLE_BLOCKED_PERIODS' ) ) {
382 define( 'LATEPOINT_TABLE_BLOCKED_PERIODS', $wpdb->prefix . 'latepoint_blocked_periods' );
383 }
384 if ( ! defined( 'LATEPOINT_TABLE_ORDERS' ) ) {
385 define( 'LATEPOINT_TABLE_ORDERS', $wpdb->prefix . 'latepoint_orders' );
386 }
387 if ( ! defined( 'LATEPOINT_TABLE_ORDER_META' ) ) {
388 define( 'LATEPOINT_TABLE_ORDER_META', $wpdb->prefix . 'latepoint_order_meta' );
389 }
390 if ( ! defined( 'LATEPOINT_TABLE_ORDER_ITEMS' ) ) {
391 define( 'LATEPOINT_TABLE_ORDER_ITEMS', $wpdb->prefix . 'latepoint_order_items' );
392 }
393 if ( ! defined( 'LATEPOINT_TABLE_ORDER_INTENTS' ) ) {
394 define( 'LATEPOINT_TABLE_ORDER_INTENTS', $wpdb->prefix . 'latepoint_order_intents' );
395 }
396 if ( ! defined( 'LATEPOINT_TABLE_ORDER_INTENT_META' ) ) {
397 define( 'LATEPOINT_TABLE_ORDER_INTENT_META', $wpdb->prefix . 'latepoint_order_intent_meta' );
398 }
399 if ( ! defined( 'LATEPOINT_TABLE_ORDER_INVOICES' ) ) {
400 define( 'LATEPOINT_TABLE_ORDER_INVOICES', $wpdb->prefix . 'latepoint_order_invoices' );
401 }
402 if ( ! defined( 'LATEPOINT_TABLE_PAYMENT_REQUESTS' ) ) {
403 define( 'LATEPOINT_TABLE_PAYMENT_REQUESTS', $wpdb->prefix . 'latepoint_payment_requests' );
404 }
405 if ( ! defined( 'LATEPOINT_TABLE_CUSTOMER_OTP_CODES' ) ) {
406 define( 'LATEPOINT_TABLE_CUSTOMER_OTP_CODES', $wpdb->prefix . 'latepoint_customer_otp_codes' );
407 }
408 if ( ! defined( 'LATEPOINT_CUSTOMER_OTP_CODE_STATUS_ACTIVE' ) ) {
409 define( 'LATEPOINT_CUSTOMER_OTP_CODE_STATUS_ACTIVE', 'active' );
410 }
411 if ( ! defined( 'LATEPOINT_CUSTOMER_OTP_CODE_STATUS_USED' ) ) {
412 define( 'LATEPOINT_CUSTOMER_OTP_CODE_STATUS_USED', 'used' );
413 }
414 if ( ! defined( 'LATEPOINT_CUSTOMER_OTP_CODE_STATUS_EXPIRED' ) ) {
415 define( 'LATEPOINT_CUSTOMER_OTP_CODE_STATUS_EXPIRED', 'expired' );
416 }
417 if ( ! defined( 'LATEPOINT_CUSTOMER_OTP_CODE_STATUS_CANCELLED' ) ) {
418 define( 'LATEPOINT_CUSTOMER_OTP_CODE_STATUS_CANCELLED', 'cancelled' );
419 }
420 if ( ! defined( 'LATEPOINT_ORDER_INTENT_STATUS_NEW' ) ) {
421 define( 'LATEPOINT_ORDER_INTENT_STATUS_NEW', 'new' );
422 }
423 if ( ! defined( 'LATEPOINT_ORDER_INTENT_STATUS_CONVERTED' ) ) {
424 define( 'LATEPOINT_ORDER_INTENT_STATUS_CONVERTED', 'converted' );
425 }
426 if ( ! defined( 'LATEPOINT_ORDER_INTENT_STATUS_PROCESSING' ) ) {
427 define( 'LATEPOINT_ORDER_INTENT_STATUS_PROCESSING', 'processing' );
428 }
429 if ( ! defined( 'LATEPOINT_ORDER_INTENT_STATUS_FAILED' ) ) {
430 define( 'LATEPOINT_ORDER_INTENT_STATUS_FAILED', 'failed' );
431 }
432
433 if ( ! defined( 'LATEPOINT_TRANSACTION_INTENT_STATUS_NEW' ) ) {
434 define( 'LATEPOINT_TRANSACTION_INTENT_STATUS_NEW', 'new' );
435 }
436 if ( ! defined( 'LATEPOINT_TRANSACTION_INTENT_STATUS_CONVERTED' ) ) {
437 define( 'LATEPOINT_TRANSACTION_INTENT_STATUS_CONVERTED', 'converted' );
438 }
439 if ( ! defined( 'LATEPOINT_TRANSACTION_INTENT_STATUS_PROCESSING' ) ) {
440 define( 'LATEPOINT_TRANSACTION_INTENT_STATUS_PROCESSING', 'processing' );
441 }
442 if ( ! defined( 'LATEPOINT_TRANSACTION_INTENT_STATUS_FAILED' ) ) {
443 define( 'LATEPOINT_TRANSACTION_INTENT_STATUS_FAILED', 'failed' );
444 }
445
446 if ( ! defined( 'LATEPOINT_BOOKING_STATUS_APPROVED' ) ) {
447 define( 'LATEPOINT_BOOKING_STATUS_APPROVED', 'approved' );
448 }
449 if ( ! defined( 'LATEPOINT_BOOKING_STATUS_PENDING' ) ) {
450 define( 'LATEPOINT_BOOKING_STATUS_PENDING', 'pending' );
451 }
452 if ( ! defined( 'LATEPOINT_BOOKING_STATUS_PAYMENT_PENDING' ) ) {
453 define( 'LATEPOINT_BOOKING_STATUS_PAYMENT_PENDING', 'payment_pending' );
454 }
455 if ( ! defined( 'LATEPOINT_BOOKING_STATUS_CANCELLED' ) ) {
456 define( 'LATEPOINT_BOOKING_STATUS_CANCELLED', 'cancelled' );
457 }
458 if ( ! defined( 'LATEPOINT_BOOKING_STATUS_NO_SHOW' ) ) {
459 define( 'LATEPOINT_BOOKING_STATUS_NO_SHOW', 'no_show' );
460 }
461 if ( ! defined( 'LATEPOINT_BOOKING_STATUS_COMPLETED' ) ) {
462 define( 'LATEPOINT_BOOKING_STATUS_COMPLETED', 'completed' );
463 }
464
465 if ( ! defined( 'LATEPOINT_JOB_STATUS_COMPLETED' ) ) {
466 define( 'LATEPOINT_JOB_STATUS_COMPLETED', 'completed' );
467 }
468 if ( ! defined( 'LATEPOINT_JOB_STATUS_SCHEDULED' ) ) {
469 define( 'LATEPOINT_JOB_STATUS_SCHEDULED', 'scheduled' );
470 }
471 if ( ! defined( 'LATEPOINT_JOB_STATUS_CANCELLED' ) ) {
472 define( 'LATEPOINT_JOB_STATUS_CANCELLED', 'cancelled' );
473 }
474 if ( ! defined( 'LATEPOINT_JOB_STATUS_ERROR' ) ) {
475 define( 'LATEPOINT_JOB_STATUS_ERROR', 'error' );
476 }
477
478 // order statuses
479 if ( ! defined( 'LATEPOINT_ORDER_STATUS_OPEN' ) ) {
480 define( 'LATEPOINT_ORDER_STATUS_OPEN', 'open' );
481 }
482 if ( ! defined( 'LATEPOINT_ORDER_STATUS_CANCELLED' ) ) {
483 define( 'LATEPOINT_ORDER_STATUS_CANCELLED', 'cancelled' );
484 }
485 if ( ! defined( 'LATEPOINT_ORDER_STATUS_COMPLETED' ) ) {
486 define( 'LATEPOINT_ORDER_STATUS_COMPLETED', 'completed' );
487 }
488
489 // order fulfillment statuses
490 if ( ! defined( 'LATEPOINT_ORDER_FULFILLMENT_STATUS_NOT_FULFILLED' ) ) {
491 define( 'LATEPOINT_ORDER_FULFILLMENT_STATUS_NOT_FULFILLED', 'not_fulfilled' );
492 }
493 if ( ! defined( 'LATEPOINT_ORDER_FULFILLMENT_STATUS_FULFILLED' ) ) {
494 define( 'LATEPOINT_ORDER_FULFILLMENT_STATUS_FULFILLED', 'fulfilled' );
495 }
496 if ( ! defined( 'LATEPOINT_ORDER_FULFILLMENT_STATUS_PARTIALLY_FULFILLED' ) ) {
497 define( 'LATEPOINT_ORDER_FULFILLMENT_STATUS_PARTIALLY_FULFILLED', 'partially_fulfilled' );
498 }
499
500 if ( ! defined( 'LATEPOINT_ORDER_PAYMENT_STATUS_NOT_PAID' ) ) {
501 define( 'LATEPOINT_ORDER_PAYMENT_STATUS_NOT_PAID', 'not_paid' );
502 }
503 if ( ! defined( 'LATEPOINT_ORDER_PAYMENT_STATUS_PARTIALLY_PAID' ) ) {
504 define( 'LATEPOINT_ORDER_PAYMENT_STATUS_PARTIALLY_PAID', 'partially_paid' );
505 }
506 if ( ! defined( 'LATEPOINT_ORDER_PAYMENT_STATUS_FULLY_PAID' ) ) {
507 define( 'LATEPOINT_ORDER_PAYMENT_STATUS_FULLY_PAID', 'fully_paid' );
508 }
509 if ( ! defined( 'LATEPOINT_ORDER_PAYMENT_STATUS_PROCESSING' ) ) {
510 define( 'LATEPOINT_ORDER_PAYMENT_STATUS_PROCESSING', 'processing' );
511 }
512 if ( ! defined( 'LATEPOINT_ORDER_PAYMENT_STATUS_REFUNDED' ) ) {
513 define( 'LATEPOINT_ORDER_PAYMENT_STATUS_REFUNDED', 'refunded' );
514 }
515 if ( ! defined( 'LATEPOINT_ORDER_PAYMENT_STATUS_PARTIALLY_REFUNDED' ) ) {
516 define( 'LATEPOINT_ORDER_PAYMENT_STATUS_PARTIALLY_REFUNDED', 'partially_refunded' );
517 }
518
519 if ( ! defined( 'LATEPOINT_DEFAULT_TIME_SYSTEM' ) ) {
520 define( 'LATEPOINT_DEFAULT_TIME_SYSTEM', '12' );
521 }
522 if ( ! defined( 'LATEPOINT_DEFAULT_DATE_FORMAT' ) ) {
523 define( 'LATEPOINT_DEFAULT_DATE_FORMAT', 'm/d/Y' );
524 }
525 if ( ! defined( 'LATEPOINT_DATETIME_DB_FORMAT' ) ) {
526 define( 'LATEPOINT_DATETIME_DB_FORMAT', 'Y-m-d H:i:s' );
527 }
528
529 if ( ! defined( 'LATEPOINT_STATUS_ERROR' ) ) {
530 define( 'LATEPOINT_STATUS_ERROR', 'error' );
531 }
532 if ( ! defined( 'LATEPOINT_STATUS_SUCCESS' ) ) {
533 define( 'LATEPOINT_STATUS_SUCCESS', 'success' );
534 }
535
536 if ( ! defined( 'LATEPOINT_SERVICE_STATUS_ACTIVE' ) ) {
537 define( 'LATEPOINT_SERVICE_STATUS_ACTIVE', 'active' );
538 }
539 if ( ! defined( 'LATEPOINT_SERVICE_STATUS_DISABLED' ) ) {
540 define( 'LATEPOINT_SERVICE_STATUS_DISABLED', 'disabled' );
541 }
542
543 if ( ! defined( 'LATEPOINT_SERVICE_VISIBILITY_VISIBLE' ) ) {
544 define( 'LATEPOINT_SERVICE_VISIBILITY_VISIBLE', 'visible' );
545 }
546 if ( ! defined( 'LATEPOINT_SERVICE_VISIBILITY_HIDDEN' ) ) {
547 define( 'LATEPOINT_SERVICE_VISIBILITY_HIDDEN', 'hidden' );
548 }
549
550
551 if ( ! defined( 'LATEPOINT_LOCATION_STATUS_ACTIVE' ) ) {
552 define( 'LATEPOINT_LOCATION_STATUS_ACTIVE', 'active' );
553 }
554 if ( ! defined( 'LATEPOINT_LOCATION_STATUS_DISABLED' ) ) {
555 define( 'LATEPOINT_LOCATION_STATUS_DISABLED', 'disabled' );
556 }
557
558 if ( ! defined( 'LATEPOINT_AGENT_STATUS_ACTIVE' ) ) {
559 define( 'LATEPOINT_AGENT_STATUS_ACTIVE', 'active' );
560 }
561 if ( ! defined( 'LATEPOINT_AGENT_STATUS_DISABLED' ) ) {
562 define( 'LATEPOINT_AGENT_STATUS_DISABLED', 'disabled' );
563 }
564
565 if ( ! defined( 'LATEPOINT_BUNDLE_STATUS_ACTIVE' ) ) {
566 define( 'LATEPOINT_BUNDLE_STATUS_ACTIVE', 'active' );
567 }
568 if ( ! defined( 'LATEPOINT_BUNDLE_STATUS_DISABLED' ) ) {
569 define( 'LATEPOINT_BUNDLE_STATUS_DISABLED', 'disabled' );
570 }
571
572 if ( ! defined( 'LATEPOINT_BUNDLE_VISIBILITY_VISIBLE' ) ) {
573 define( 'LATEPOINT_BUNDLE_VISIBILITY_VISIBLE', 'visible' );
574 }
575 if ( ! defined( 'LATEPOINT_BUNDLE_VISIBILITY_HIDDEN' ) ) {
576 define( 'LATEPOINT_BUNDLE_VISIBILITY_HIDDEN', 'hidden' );
577 }
578
579 if ( ! defined( 'LATEPOINT_ITEM_VARIANT_BOOKING' ) ) {
580 define( 'LATEPOINT_ITEM_VARIANT_BOOKING', 'booking' );
581 }
582 if ( ! defined( 'LATEPOINT_ITEM_VARIANT_BUNDLE' ) ) {
583 define( 'LATEPOINT_ITEM_VARIANT_BUNDLE', 'bundle' );
584 }
585
586 if ( ! defined( 'LATEPOINT_DEFAULT_TIMEBLOCK_INTERVAL' ) ) {
587 define( 'LATEPOINT_DEFAULT_TIMEBLOCK_INTERVAL', 30 );
588 }
589 if ( ! defined( 'LATEPOINT_DEFAULT_PHONE_CODE' ) ) {
590 define( 'LATEPOINT_DEFAULT_PHONE_CODE', '+1' );
591 }
592 if ( ! defined( 'LATEPOINT_DEFAULT_PHONE_FORMAT' ) ) {
593 define( 'LATEPOINT_DEFAULT_PHONE_FORMAT', '(999) 999-9999' );
594 }
595
596 if ( ! defined( 'LATEPOINT_TRANSACTION_STATUS_SUCCEEDED' ) ) {
597 define( 'LATEPOINT_TRANSACTION_STATUS_SUCCEEDED', 'succeeded' );
598 }
599 if ( ! defined( 'LATEPOINT_TRANSACTION_STATUS_PROCESSING' ) ) {
600 define( 'LATEPOINT_TRANSACTION_STATUS_PROCESSING', 'processing' );
601 }
602 if ( ! defined( 'LATEPOINT_TRANSACTION_STATUS_FAILED' ) ) {
603 define( 'LATEPOINT_TRANSACTION_STATUS_FAILED', 'failed' );
604 }
605
606 // invoices
607 if ( ! defined( 'LATEPOINT_INVOICE_STATUS_OPEN' ) ) {
608 define( 'LATEPOINT_INVOICE_STATUS_OPEN', 'open' );
609 }
610 if ( ! defined( 'LATEPOINT_INVOICE_STATUS_PAID' ) ) {
611 define( 'LATEPOINT_INVOICE_STATUS_PAID', 'paid' );
612 }
613 if ( ! defined( 'LATEPOINT_INVOICE_STATUS_PARTIALLY_PAID' ) ) {
614 define( 'LATEPOINT_INVOICE_STATUS_PARTIALLY_PAID', 'partially_paid' );
615 }
616 if ( ! defined( 'LATEPOINT_INVOICE_STATUS_DRAFT' ) ) {
617 define( 'LATEPOINT_INVOICE_STATUS_DRAFT', 'draft' );
618 }
619 if ( ! defined( 'LATEPOINT_INVOICE_STATUS_VOID' ) ) {
620 define( 'LATEPOINT_INVOICE_STATUS_VOID', 'void' );
621 }
622 if ( ! defined( 'LATEPOINT_INVOICE_STATUS_UNCOLLECTIBLE' ) ) {
623 define( 'LATEPOINT_INVOICE_STATUS_UNCOLLECTIBLE', 'uncollectible' );
624 }
625
626 // PAYMENTS
627
628 if ( ! defined( 'LATEPOINT_PAYMENT_PROCESSOR_STRIPE' ) ) {
629 define( 'LATEPOINT_PAYMENT_PROCESSOR_STRIPE', 'stripe' );
630 }
631 if ( ! defined( 'LATEPOINT_PAYMENT_PROCESSOR_BRAINTREE' ) ) {
632 define( 'LATEPOINT_PAYMENT_PROCESSOR_BRAINTREE', 'braintree' );
633 }
634 if ( ! defined( 'LATEPOINT_PAYMENT_PROCESSOR_PAYPAL' ) ) {
635 define( 'LATEPOINT_PAYMENT_PROCESSOR_PAYPAL', 'paypal' );
636 }
637
638 if ( ! defined( 'LATEPOINT_TRANSACTION_KIND_CAPTURE' ) ) {
639 define( 'LATEPOINT_TRANSACTION_KIND_CAPTURE', 'capture' );
640 }
641 if ( ! defined( 'LATEPOINT_TRANSACTION_KIND_AUTHORIZATION' ) ) {
642 define( 'LATEPOINT_TRANSACTION_KIND_AUTHORIZATION', 'authorization' );
643 }
644 if ( ! defined( 'LATEPOINT_TRANSACTION_KIND_VOID' ) ) {
645 define( 'LATEPOINT_TRANSACTION_KIND_VOID', 'void' );
646 }
647
648 if ( ! defined( 'LATEPOINT_PAYMENT_METHOD_LOCAL' ) ) {
649 define( 'LATEPOINT_PAYMENT_METHOD_LOCAL', 'local' );
650 }
651 if ( ! defined( 'LATEPOINT_PAYMENT_METHOD_PAYPAL' ) ) {
652 define( 'LATEPOINT_PAYMENT_METHOD_PAYPAL', 'paypal' );
653 }
654 if ( ! defined( 'LATEPOINT_PAYMENT_METHOD_CARD' ) ) {
655 define( 'LATEPOINT_PAYMENT_METHOD_CARD', 'card' );
656 }
657
658 if ( ! defined( 'LATEPOINT_PAYMENT_TIME_LATER' ) ) {
659 define( 'LATEPOINT_PAYMENT_TIME_LATER', 'later' );
660 }
661 if ( ! defined( 'LATEPOINT_PAYMENT_TIME_NOW' ) ) {
662 define( 'LATEPOINT_PAYMENT_TIME_NOW', 'now' );
663 }
664
665 if ( ! defined( 'LATEPOINT_VALUE_ON' ) ) {
666 define( 'LATEPOINT_VALUE_ON', 'on' );
667 }
668 if ( ! defined( 'LATEPOINT_VALUE_OFF' ) ) {
669 define( 'LATEPOINT_VALUE_OFF', 'off' );
670 }
671
672 if ( ! defined( 'LATEPOINT_STATUS_ACTIVE' ) ) {
673 define( 'LATEPOINT_STATUS_ACTIVE', 'active' );
674 }
675 if ( ! defined( 'LATEPOINT_STATUS_DISABLED' ) ) {
676 define( 'LATEPOINT_STATUS_DISABLED', 'disabled' );
677 }
678
679 if ( ! defined( 'LATEPOINT_PAYMENT_PORTION_FULL' ) ) {
680 define( 'LATEPOINT_PAYMENT_PORTION_FULL', 'full' );
681 }
682 if ( ! defined( 'LATEPOINT_PAYMENT_PORTION_REMAINING' ) ) {
683 define( 'LATEPOINT_PAYMENT_PORTION_REMAINING', 'remaining' );
684 }
685 if ( ! defined( 'LATEPOINT_PAYMENT_PORTION_DEPOSIT' ) ) {
686 define( 'LATEPOINT_PAYMENT_PORTION_DEPOSIT', 'deposit' );
687 }
688 if ( ! defined( 'LATEPOINT_PAYMENT_PORTION_CUSTOM' ) ) {
689 define( 'LATEPOINT_PAYMENT_PORTION_CUSTOM', 'custom' );
690 }
691
692 if ( ! defined( 'LATEPOINT_ANY_AGENT' ) ) {
693 define( 'LATEPOINT_ANY_AGENT', 'any' );
694 }
695 if ( ! defined( 'LATEPOINT_ANY_LOCATION' ) ) {
696 define( 'LATEPOINT_ANY_LOCATION', 'any' );
697 }
698
699 if ( ! defined( 'LATEPOINT_ANY_AGENT_ORDER_RANDOM' ) ) {
700 define( 'LATEPOINT_ANY_AGENT_ORDER_RANDOM', 'random' );
701 }
702 if ( ! defined( 'LATEPOINT_ANY_AGENT_ORDER_PRICE_HIGH' ) ) {
703 define( 'LATEPOINT_ANY_AGENT_ORDER_PRICE_HIGH', 'price_high' );
704 }
705 if ( ! defined( 'LATEPOINT_ANY_AGENT_ORDER_PRICE_LOW' ) ) {
706 define( 'LATEPOINT_ANY_AGENT_ORDER_PRICE_LOW', 'price_low' );
707 }
708 if ( ! defined( 'LATEPOINT_ANY_AGENT_ORDER_BUSY_HIGH' ) ) {
709 define( 'LATEPOINT_ANY_AGENT_ORDER_BUSY_HIGH', 'busy_high' );
710 }
711 if ( ! defined( 'LATEPOINT_ANY_AGENT_ORDER_BUSY_LOW' ) ) {
712 define( 'LATEPOINT_ANY_AGENT_ORDER_BUSY_LOW', 'busy_low' );
713 }
714 if ( ! defined( 'LATEPOINT_RECURRING_BOOKINGS_UNFOLDED_COUNT' ) ) {
715 define( 'LATEPOINT_RECURRING_BOOKINGS_UNFOLDED_COUNT', 5 );
716 }
717
718 if ( ! defined( 'LATEPOINT_ALL' ) ) {
719 define( 'LATEPOINT_ALL', 'all' );
720 }
721
722 // Latepoint APP URL
723 if ( ! defined( 'LATEPOINT_APP_CONNECT_URL' ) ) {
724 define( 'LATEPOINT_APP_CONNECT_URL', 'https://app.latepoint.com' );
725 }
726
727 // Stripe Connect
728 if ( ! defined( 'LATEPOINT_STRIPE_CONNECT_URL' ) ) {
729 define( 'LATEPOINT_STRIPE_CONNECT_URL', LATEPOINT_APP_CONNECT_URL );
730 }
731 }
732
733
734 /**
735 * Include required core files used in admin and on the frontend.
736 */
737 public function includes() {
738
739 // CONTROLLERS
740 include_once LATEPOINT_ABSPATH . 'lib/controllers/controller.php';
741 include_once LATEPOINT_ABSPATH . 'lib/controllers/pro_controller.php';
742 include_once LATEPOINT_ABSPATH . 'lib/controllers/default_agent_controller.php';
743 include_once LATEPOINT_ABSPATH . 'lib/controllers/activities_controller.php';
744 include_once LATEPOINT_ABSPATH . 'lib/controllers/search_controller.php';
745 include_once LATEPOINT_ABSPATH . 'lib/controllers/customers_controller.php';
746 include_once LATEPOINT_ABSPATH . 'lib/controllers/services_controller.php';
747 include_once LATEPOINT_ABSPATH . 'lib/controllers/carts_controller.php';
748 include_once LATEPOINT_ABSPATH . 'lib/controllers/transactions_controller.php';
749 include_once LATEPOINT_ABSPATH . 'lib/controllers/orders_controller.php';
750 include_once LATEPOINT_ABSPATH . 'lib/controllers/auth_controller.php';
751 include_once LATEPOINT_ABSPATH . 'lib/controllers/processes_controller.php';
752 include_once LATEPOINT_ABSPATH . 'lib/controllers/process_jobs_controller.php';
753 include_once LATEPOINT_ABSPATH . 'lib/controllers/settings_controller.php';
754 include_once LATEPOINT_ABSPATH . 'lib/controllers/form_fields_controller.php';
755 include_once LATEPOINT_ABSPATH . 'lib/controllers/bookings_controller.php';
756 include_once LATEPOINT_ABSPATH . 'lib/controllers/dashboard_controller.php';
757 include_once LATEPOINT_ABSPATH . 'lib/controllers/wizard_controller.php';
758 include_once LATEPOINT_ABSPATH . 'lib/controllers/notifications_controller.php';
759 include_once LATEPOINT_ABSPATH . 'lib/controllers/steps_controller.php';
760 include_once LATEPOINT_ABSPATH . 'lib/controllers/calendars_controller.php';
761 include_once LATEPOINT_ABSPATH . 'lib/controllers/booking_form_settings_controller.php';
762 include_once LATEPOINT_ABSPATH . 'lib/controllers/integrations_controller.php';
763 include_once LATEPOINT_ABSPATH . 'lib/controllers/customer_cabinet_controller.php';
764 include_once LATEPOINT_ABSPATH . 'lib/controllers/manage_booking_by_key_controller.php';
765 include_once LATEPOINT_ABSPATH . 'lib/controllers/manage_order_by_key_controller.php';
766 include_once LATEPOINT_ABSPATH . 'lib/controllers/events_controller.php';
767 include_once LATEPOINT_ABSPATH . 'lib/controllers/stripe_connect_controller.php';
768 include_once LATEPOINT_ABSPATH . 'lib/controllers/invoices_controller.php';
769 include_once LATEPOINT_ABSPATH . 'lib/controllers/support_topics_controller.php';
770
771
772 // MODELS
773 include_once LATEPOINT_ABSPATH . 'lib/models/model.php';
774 include_once LATEPOINT_ABSPATH . 'lib/models/meta_model.php';
775 include_once LATEPOINT_ABSPATH . 'lib/models/bundle_model.php';
776 include_once LATEPOINT_ABSPATH . 'lib/models/cart_model.php';
777 include_once LATEPOINT_ABSPATH . 'lib/models/cart_meta_model.php';
778 include_once LATEPOINT_ABSPATH . 'lib/models/cart_item_model.php';
779 include_once LATEPOINT_ABSPATH . 'lib/models/order_model.php';
780 include_once LATEPOINT_ABSPATH . 'lib/models/order_meta_model.php';
781 include_once LATEPOINT_ABSPATH . 'lib/models/order_item_model.php';
782 include_once LATEPOINT_ABSPATH . 'lib/models/activity_model.php';
783 include_once LATEPOINT_ABSPATH . 'lib/models/work_period_model.php';
784 include_once LATEPOINT_ABSPATH . 'lib/models/agent_model.php';
785 include_once LATEPOINT_ABSPATH . 'lib/models/service_model.php';
786 include_once LATEPOINT_ABSPATH . 'lib/models/connector_model.php';
787 include_once LATEPOINT_ABSPATH . 'lib/models/service_category_model.php';
788 include_once LATEPOINT_ABSPATH . 'lib/models/customer_model.php';
789 include_once LATEPOINT_ABSPATH . 'lib/models/settings_model.php';
790 include_once LATEPOINT_ABSPATH . 'lib/models/booking_model.php';
791 include_once LATEPOINT_ABSPATH . 'lib/models/step_settings_model.php';
792 include_once LATEPOINT_ABSPATH . 'lib/models/transaction_model.php';
793 include_once LATEPOINT_ABSPATH . 'lib/models/transaction_intent_model.php';
794 include_once LATEPOINT_ABSPATH . 'lib/models/transaction_refund_model.php';
795 include_once LATEPOINT_ABSPATH . 'lib/models/booking_meta_model.php';
796 include_once LATEPOINT_ABSPATH . 'lib/models/customer_meta_model.php';
797 include_once LATEPOINT_ABSPATH . 'lib/models/agent_meta_model.php';
798 include_once LATEPOINT_ABSPATH . 'lib/models/service_meta_model.php';
799 include_once LATEPOINT_ABSPATH . 'lib/models/bundle_meta_model.php';
800 include_once LATEPOINT_ABSPATH . 'lib/models/location_model.php';
801 include_once LATEPOINT_ABSPATH . 'lib/models/location_category_model.php';
802 include_once LATEPOINT_ABSPATH . 'lib/models/session_model.php';
803 include_once LATEPOINT_ABSPATH . 'lib/models/order_intent_model.php';
804 include_once LATEPOINT_ABSPATH . 'lib/models/order_intent_meta_model.php';
805 include_once LATEPOINT_ABSPATH . 'lib/models/process_model.php';
806 include_once LATEPOINT_ABSPATH . 'lib/models/process_job_model.php';
807 include_once LATEPOINT_ABSPATH . 'lib/models/join_bundles_services_model.php';
808 include_once LATEPOINT_ABSPATH . 'lib/models/invoice_model.php';
809 include_once LATEPOINT_ABSPATH . 'lib/models/payment_request_model.php';
810 include_once LATEPOINT_ABSPATH . 'lib/models/recurrence_model.php';
811 include_once LATEPOINT_ABSPATH . 'lib/models/off_period_model.php';
812 include_once LATEPOINT_ABSPATH . 'lib/models/otp_model.php';
813
814
815 // HELPERS
816 include_once LATEPOINT_ABSPATH . 'lib/helpers/wp_datetime.php';
817 include_once LATEPOINT_ABSPATH . 'lib/helpers/router_helper.php';
818 include_once LATEPOINT_ABSPATH . 'lib/helpers/sessions_helper.php';
819 include_once LATEPOINT_ABSPATH . 'lib/helpers/auth_helper.php';
820 include_once LATEPOINT_ABSPATH . 'lib/helpers/encrypt_helper.php';
821 include_once LATEPOINT_ABSPATH . 'lib/helpers/license_helper.php';
822 include_once LATEPOINT_ABSPATH . 'lib/helpers/form_helper.php';
823 include_once LATEPOINT_ABSPATH . 'lib/helpers/migrations_helper.php';
824 include_once LATEPOINT_ABSPATH . 'lib/helpers/util_helper.php';
825 include_once LATEPOINT_ABSPATH . 'lib/helpers/debug_helper.php';
826 include_once LATEPOINT_ABSPATH . 'lib/helpers/wp_user_helper.php';
827 include_once LATEPOINT_ABSPATH . 'lib/helpers/menu_helper.php';
828 include_once LATEPOINT_ABSPATH . 'lib/helpers/image_helper.php';
829 include_once LATEPOINT_ABSPATH . 'lib/helpers/events_helper.php';
830 include_once LATEPOINT_ABSPATH . 'lib/helpers/icalendar_helper.php';
831 include_once LATEPOINT_ABSPATH . 'lib/helpers/version_specific_updates_helper.php';
832 include_once LATEPOINT_ABSPATH . 'lib/helpers/calendar_helper.php';
833 include_once LATEPOINT_ABSPATH . 'lib/helpers/meeting_systems_helper.php';
834 include_once LATEPOINT_ABSPATH . 'lib/helpers/marketing_systems_helper.php';
835 include_once LATEPOINT_ABSPATH . 'lib/helpers/short_links_systems_helper.php';
836 include_once LATEPOINT_ABSPATH . 'lib/helpers/timeline_helper.php';
837 include_once LATEPOINT_ABSPATH . 'lib/helpers/booking_helper.php';
838 include_once LATEPOINT_ABSPATH . 'lib/helpers/order_intent_helper.php';
839 include_once LATEPOINT_ABSPATH . 'lib/helpers/activities_helper.php';
840 include_once LATEPOINT_ABSPATH . 'lib/helpers/settings_helper.php';
841 include_once LATEPOINT_ABSPATH . 'lib/helpers/customer_helper.php';
842 include_once LATEPOINT_ABSPATH . 'lib/helpers/customer_import_helper.php';
843 include_once LATEPOINT_ABSPATH . 'lib/helpers/processes_helper.php';
844 include_once LATEPOINT_ABSPATH . 'lib/helpers/agent_helper.php';
845 include_once LATEPOINT_ABSPATH . 'lib/helpers/service_helper.php';
846 include_once LATEPOINT_ABSPATH . 'lib/helpers/database_helper.php';
847 include_once LATEPOINT_ABSPATH . 'lib/helpers/money_helper.php';
848 include_once LATEPOINT_ABSPATH . 'lib/helpers/time_helper.php';
849 include_once LATEPOINT_ABSPATH . 'lib/helpers/notifications_helper.php';
850 include_once LATEPOINT_ABSPATH . 'lib/helpers/email_helper.php';
851 include_once LATEPOINT_ABSPATH . 'lib/helpers/sms_helper.php';
852 include_once LATEPOINT_ABSPATH . 'lib/helpers/whatsapp_helper.php';
853 include_once LATEPOINT_ABSPATH . 'lib/helpers/styles_helper.php';
854 include_once LATEPOINT_ABSPATH . 'lib/helpers/work_periods_helper.php';
855 include_once LATEPOINT_ABSPATH . 'lib/helpers/bundles_helper.php';
856 include_once LATEPOINT_ABSPATH . 'lib/helpers/carts_helper.php';
857 include_once LATEPOINT_ABSPATH . 'lib/helpers/orders_helper.php';
858 include_once LATEPOINT_ABSPATH . 'lib/helpers/replacer_helper.php';
859 include_once LATEPOINT_ABSPATH . 'lib/helpers/payments_helper.php';
860 include_once LATEPOINT_ABSPATH . 'lib/helpers/resource_helper.php';
861 include_once LATEPOINT_ABSPATH . 'lib/helpers/meta_helper.php';
862 include_once LATEPOINT_ABSPATH . 'lib/helpers/shortcodes_helper.php';
863 include_once LATEPOINT_ABSPATH . 'lib/helpers/connector_helper.php';
864 include_once LATEPOINT_ABSPATH . 'lib/helpers/location_helper.php';
865 include_once LATEPOINT_ABSPATH . 'lib/helpers/csv_helper.php';
866 include_once LATEPOINT_ABSPATH . 'lib/helpers/steps_helper.php';
867 include_once LATEPOINT_ABSPATH . 'lib/helpers/params_helper.php';
868 include_once LATEPOINT_ABSPATH . 'lib/helpers/process_jobs_helper.php';
869 include_once LATEPOINT_ABSPATH . 'lib/helpers/blocks_helper.php';
870 include_once LATEPOINT_ABSPATH . 'lib/helpers/roles_helper.php';
871 include_once LATEPOINT_ABSPATH . 'lib/helpers/price_breakdown_helper.php';
872 include_once LATEPOINT_ABSPATH . 'lib/helpers/stripe_connect_helper.php';
873 include_once LATEPOINT_ABSPATH . 'lib/helpers/pages_helper.php';
874 include_once LATEPOINT_ABSPATH . 'lib/helpers/elementor_helper.php';
875 include_once LATEPOINT_ABSPATH . 'lib/helpers/bricks_helper.php';
876 include_once LATEPOINT_ABSPATH . 'lib/helpers/transaction_intent_helper.php';
877 include_once LATEPOINT_ABSPATH . 'lib/helpers/transaction_helper.php';
878 include_once LATEPOINT_ABSPATH . 'lib/helpers/invoices_helper.php';
879 include_once LATEPOINT_ABSPATH . 'lib/helpers/support_topics_helper.php';
880 include_once LATEPOINT_ABSPATH . 'lib/helpers/otp_helper.php';
881 include_once LATEPOINT_ABSPATH . 'lib/helpers/nps_survey_helper.php';
882 include_once LATEPOINT_ABSPATH . 'lib/helpers/analytics_helper.php';
883
884 // MISC
885 include_once LATEPOINT_ABSPATH . 'lib/misc/time_period.php';
886 include_once LATEPOINT_ABSPATH . 'lib/misc/blocked_period.php';
887 include_once LATEPOINT_ABSPATH . 'lib/misc/booked_period.php';
888 include_once LATEPOINT_ABSPATH . 'lib/misc/stripe_connect_customer.php';
889 include_once LATEPOINT_ABSPATH . 'lib/misc/booking_request.php';
890 include_once LATEPOINT_ABSPATH . 'lib/misc/booking_resource.php';
891 include_once LATEPOINT_ABSPATH . 'lib/misc/work_period.php';
892 include_once LATEPOINT_ABSPATH . 'lib/misc/filter.php';
893 include_once LATEPOINT_ABSPATH . 'lib/misc/booking_slot.php';
894 include_once LATEPOINT_ABSPATH . 'lib/misc/process_event.php';
895 include_once LATEPOINT_ABSPATH . 'lib/misc/process_action.php';
896 include_once LATEPOINT_ABSPATH . 'lib/misc/role.php';
897 include_once LATEPOINT_ABSPATH . 'lib/misc/user.php';
898 include_once LATEPOINT_ABSPATH . 'lib/misc/step.php';
899 include_once LATEPOINT_ABSPATH . 'lib/misc/router.php';
900
901 // MAILERS
902 include_once LATEPOINT_ABSPATH . 'lib/mailers/mailer.php';
903 include_once LATEPOINT_ABSPATH . 'lib/mailers/agent_mailer.php';
904 include_once LATEPOINT_ABSPATH . 'lib/mailers/customer_mailer.php';
905
906 // ABILITIES (WordPress 6.9+ Abilities API)
907 if ( function_exists( 'wp_register_ability' ) ) {
908 include_once LATEPOINT_ABSPATH . 'lib/abilities/class-latepoint-abilities.php';
909 }
910
911 do_action( 'latepoint_includes' );
912 }
913
914
915 /**
916 * Hook into actions and filters.
917 */
918 public function init_hooks() {
919 if ( isset( $_GET['latepoint'] ) && $_GET['latepoint'] == 'instant' ) {
920 add_action( 'init', array( $this, 'public_route_call' ), 100 );
921 }
922 $siteurl = get_site_option( 'siteurl' );
923 if ( $siteurl ) {
924 $siteurl_hash = md5( $siteurl );
925 } else {
926 $siteurl_hash = '';
927 }
928
929 if ( ! defined( 'LATEPOINT_CUSTOMER_LOGGED_IN_COOKIE' ) ) {
930 define( 'LATEPOINT_CUSTOMER_LOGGED_IN_COOKIE', 'latepoint_customer_logged_in_' . $siteurl_hash );
931 }
932 if ( ! defined( 'LATEPOINT_ADMIN_MENU_LAYOUT_STYLE_COOKIE' ) ) {
933 define( 'LATEPOINT_ADMIN_MENU_LAYOUT_STYLE_COOKIE', 'latepoint_admin_menu_layout_style_' . $siteurl_hash );
934 }
935 if ( ! defined( 'LATEPOINT_SELECTED_TIMEZONE_COOKIE' ) ) {
936 define( 'LATEPOINT_SELECTED_TIMEZONE_COOKIE', 'latepoint_selected_timezone_' . $siteurl_hash );
937 }
938
939 if ( ! defined( 'LATEPOINT_CART_COOKIE' ) ) {
940 define( 'LATEPOINT_CART_COOKIE', 'latepoint_cart_' . $siteurl_hash );
941 }
942
943 // Plugins loaded
944 add_action( 'plugins_loaded', array( $this, 'plugins_loaded_hook' ) );
945
946 // Addon version compatibility checks.
947 add_action( 'admin_init', array( $this, 'check_addon_versions' ) );
948
949 // Activation / deactivation hooks.
950 register_activation_hook( __FILE__, array( $this, 'create_required_tables' ) );
951 register_activation_hook( __FILE__, array( $this, 'on_activate' ) );
952 register_deactivation_hook( __FILE__, [ $this, 'on_deactivate' ] );
953
954 add_action( 'after_setup_theme', array( $this, 'setup_environment' ) );
955 add_action( 'init', array( $this, 'init' ), 0 );
956 add_action( 'init', array( $this, 'init_widgets' ), 11 );
957
958 add_action( 'admin_menu', array( $this, 'init_menus' ) );
959 add_action( 'wp_enqueue_scripts', array( $this, 'load_front_scripts_and_styles' ) );
960 add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts_and_styles' ) );
961 add_filter( 'admin_body_class', array( $this, 'add_admin_body_class' ), 40 );
962 add_filter( 'body_class', array( $this, 'add_body_class' ) );
963
964 add_filter( 'cron_schedules', [ $this, 'add_custom_cron_schedules' ] );
965
966 // used for testing of localhost to prevent wordpress issues with getting files from local server
967 if ( LATEPOINT_ALLOW_LOCAL_SERVER ) {
968 add_filter( 'http_request_args', [ $this, 'disable_localhost_url_check_for_development' ] );
969 }
970
971 // Add Link to latepoint to admin bar
972 add_action( 'admin_bar_menu', array( $this, 'add_latepoint_link_to_admin_bar' ), 999 );
973
974
975 // fix for output buffering error in WP
976 // remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
977
978 add_action( 'wp_loaded', array( $this, 'pre_route_call' ) );
979
980
981 // Create router action
982 // ajax
983 add_action( 'wp_ajax_latepoint_route_call', array( $this, 'route_call' ) );
984 add_action( 'wp_ajax_nopriv_latepoint_route_call', array( $this, 'route_call' ) );
985 // admin custom post/get
986 add_action( 'admin_post_latepoint_route_call', array( $this, 'route_call' ) );
987 add_action( 'admin_post_nopriv_latepoint_route_call', array( $this, 'route_call' ) );
988
989 // crons
990 add_action( 'latepoint_clear_old_activity_logs', [ $this, 'clear_old_activity_logs' ] );
991
992
993 add_action( 'latepoint_on_addon_activate', [ $this, 'addon_activated' ], 10, 2 );
994 add_action( 'latepoint_on_addon_deactivate', [ $this, 'addon_deactivated' ], 10, 2 );
995
996
997 add_action( 'latepoint_email_processor_settings', [ $this, 'email_processor_settings' ], 10, 2 );
998
999
1000 // Auth
1001 add_filter( 'login_redirect', [ $this, 'redirect_manager_and_agent_to_latepoint' ], 10, 3 );
1002
1003
1004 // But WordPress has a whitelist of variables it allows, so we must put it on that list
1005 add_action( 'query_vars', array( $this, 'front_route_query_vars' ) );
1006
1007 // If this is done, we can access it later
1008 // This example checks very early in the process:
1009 // if the variable is set, we include our page and stop execution after it
1010 add_action( 'parse_request', array( $this, 'front_route_parse_request' ) );
1011
1012
1013 add_action( 'admin_init', array( $this, 'redirect_after_activation' ) );
1014
1015 add_filter( 'display_post_states', 'OsPagesHelper::add_display_post_states', 10, 2 );
1016
1017 // allow agents to access admin when woocommerce plugin is installed
1018 add_filter( 'woocommerce_prevent_admin_access', [ $this, 'woocommerce_allow_agent_to_access_admin' ], 20, 1 );
1019
1020 // plugin related hooks
1021 add_action( 'latepoint_model_save', [ $this, 'save_connected_wordpress_user' ] );
1022
1023 // Stripe Connect
1024
1025 add_filter( 'latepoint_payment_processors', 'OsStripeConnectHelper::register_payment_processor' );
1026 add_action( 'latepoint_payment_processor_settings', 'OsStripeConnectHelper::add_settings_fields', 10 );
1027 add_action( 'latepoint_step_payment__pay_content', 'OsStripeConnectHelper::output_payment_step_contents', 10 );
1028 add_action( 'latepoint_order_payment__pay_content_after', 'OsStripeConnectHelper::output_order_payment_pay_contents', 10 );
1029
1030 add_filter( 'latepoint_convert_charge_amount_to_requirements', 'OsStripeConnectHelper::convert_charge_amount_to_requirements', 10, 2 );
1031 add_filter( 'latepoint_process_payment_for_order_intent', 'OsStripeConnectHelper::process_payment', 10, 2 );
1032 add_filter( 'latepoint_process_payment_for_transaction_intent', 'OsStripeConnectHelper::process_payment_for_transaction_intent', 10, 2 );
1033 add_filter( 'latepoint_transaction_intent_specs_charge_amount', 'OsStripeConnectHelper::convert_transaction_intent_charge_amount_to_specs', 10, 2 );
1034
1035 add_filter( 'latepoint_get_all_payment_times', 'OsStripeConnectHelper::add_all_payment_methods_to_payment_times' );
1036 add_filter( 'latepoint_get_enabled_payment_times', 'OsStripeConnectHelper::add_enabled_payment_methods_to_payment_times' );
1037 add_filter( 'latepoint_transaction_is_refund_available', 'OsStripeConnectHelper::transaction_is_refund_available', 10, 2 );
1038 add_filter( 'latepoint_process_refund', 'OsStripeConnectHelper::process_refund', 10, 3 );
1039 add_filter( 'plugin_action_links', [ $this, 'add_upgrade_link' ], 10, 2 );
1040
1041
1042 add_action( 'latepoint_customer_edit_form_after', 'OsStripeConnectHelper::output_stripe_link_on_customer_quick_form' );
1043
1044 add_action( 'save_post', 'OsBlockHelper::save_blocks_styles' );
1045 // misc
1046 add_action( 'latepoint_after_step_content', 'OsStepsHelper::output_preset_fields' );
1047
1048 OsActivitiesHelper::init_hooks();
1049 OsProcessJobsHelper::init_hooks();
1050
1051 // Initialize NPS Survey.
1052 OsNpsSurveyHelper::get_instance();
1053
1054 do_action( 'latepoint_init_hooks' );
1055 }
1056
1057 function plugins_loaded_hook() {
1058 OsAnalyticsHelper::init();
1059 }
1060
1061 function check_addon_versions() {
1062 if ( ! current_user_can( 'update_plugins' ) ) {
1063 return;
1064 }
1065
1066 if (
1067 defined( 'LATEPOINT_ADDON_PRO_VERSION' )
1068 && defined( 'LATEPOINT_MIN_REQUIRED_PRO_VERSION' )
1069 && version_compare( LATEPOINT_ADDON_PRO_VERSION, LATEPOINT_MIN_REQUIRED_PRO_VERSION, '<' )
1070 ) {
1071 add_action( 'admin_notices', array( $this, 'pro_version_outdated_notice' ) );
1072 }
1073 }
1074
1075 function pro_version_outdated_notice() {
1076 $screen = get_current_screen();
1077 if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
1078 return;
1079 }
1080
1081 $message = sprintf(
1082 /* translators: 1: bold open tag, 2: bold close tag, 3: required version, 4: current version */
1083 __( 'You are using an older version of the %1$sLatePoint Pro Features%2$s plugin (v%4$s). Please update the %1$sLatePoint Pro Features%2$s plugin to version %1$s%3$s or later%2$s.', 'latepoint' ),
1084 '<strong>',
1085 '</strong>',
1086 esc_html( LATEPOINT_MIN_REQUIRED_PRO_VERSION ),
1087 esc_html( LATEPOINT_ADDON_PRO_VERSION )
1088 );
1089 $button = '<p><a href="' . esc_url( self_admin_url( 'plugins.php' ) ) . '" class="button-primary">'
1090 . esc_html__( 'Update Now', 'latepoint' ) . '</a></p>';
1091
1092 printf(
1093 '<div class="notice notice-warning"><p>%1$s</p>%2$s</div>',
1094 wp_kses_post( $message ),
1095 wp_kses_post( $button )
1096 );
1097 }
1098
1099 function add_custom_cron_schedules( $schedules ) {
1100 if ( ! isset( $schedules['latepoint_5_minutes'] ) ) {
1101 $schedules['latepoint_5_minutes'] = array(
1102 'interval' => 5 * 60,
1103 'display' => __( 'Once every 5 minutes', 'latepoint' ),
1104 );
1105 }
1106
1107 return $schedules;
1108 }
1109
1110 function add_upgrade_link( $links, $plugin_file ) {
1111 if ( plugin_basename( __FILE__ ) == $plugin_file ) {
1112 if ( apply_filters( 'latepoint_show_upgrade_link_on_plugins_page', true, $plugin_file ) ) {
1113 $custom_link = '<a class="latepoint-plugin-upgrade-premium-link" href="' . LATEPOINT_UPGRADE_URL . '">' . esc_html__( 'Get LatePoint Pro' ) . '</a>';
1114 $links[] = $custom_link;
1115 }
1116 }
1117
1118 return $links;
1119 }
1120
1121 function woocommerce_allow_agent_to_access_admin( $prevent_access ) {
1122 if ( OsAuthHelper::is_agent_logged_in() ) {
1123 $prevent_access = false;
1124 }
1125
1126 return $prevent_access;
1127 }
1128
1129 function email_processor_settings( $processor_code ) {
1130 if ( $processor_code == 'wp_mail' ) {
1131 echo '<div class="sub-section-row">
1132 <div class="sub-section-label">
1133 <h3>' . esc_html__( 'Email Settings', 'latepoint' ) . '</h3>
1134 </div>
1135 <div class="sub-section-content">
1136 <div class="os-row">
1137 <div class="os-col-4">' . OsFormHelper::text_field( 'settings[notification_email_setting_from_name]', __( 'From Name', 'latepoint' ), OsSettingsHelper::get_settings_value( 'notification_email_setting_from_name', get_bloginfo( 'name' ) ), [ 'theme' => 'simple' ] ) . '</div>
1138 <div class="os-col-8">' . OsFormHelper::text_field( 'settings[notification_email_setting_from_email]', __( 'From Email Address', 'latepoint' ), OsSettingsHelper::get_settings_value( 'notification_email_setting_from_email', get_bloginfo( 'admin_email' ) ), [ 'theme' => 'simple' ] ) . '</div>
1139 </div>
1140 </div>
1141 </div>';
1142 }
1143 }
1144
1145 public function save_connected_wordpress_user( $customer ) {
1146 if ( $customer->is_new_record() ) {
1147 return;
1148 }
1149 if ( $customer instanceof OsCustomerModel ) {
1150 if ( $customer->wordpress_user_id ) {
1151 // has connected wp user
1152 $wp_user = get_user_by( 'id', $customer->wordpress_user_id );
1153 if ( $wp_user && ! is_super_admin( $wp_user->ID ) ) {
1154 // update linked wordpress user
1155 if ( $customer->first_name && $customer->first_name != $wp_user->first_name ) {
1156 $wp_user->first_name = $customer->first_name;
1157 }
1158 if ( $customer->last_name && $customer->last_name != $wp_user->last_name ) {
1159 $wp_user->last_name = $customer->last_name;
1160 }
1161 if ( $customer->email && $customer->email != $wp_user->user_email ) {
1162 $wp_user->user_email = $customer->email;
1163 }
1164 $result = wp_update_user( $wp_user );
1165 if ( is_wp_error( $result ) ) {
1166 error_log( 'Error saving wp user' );
1167 } else {
1168 // update user cookies because their data has changed
1169 }
1170 }
1171 } else {
1172 if ( OsAuthHelper::can_wp_users_login_as_customers() ) {
1173 OsCustomerHelper::create_wp_user_for_customer( $customer );
1174 }
1175 }
1176 }
1177 }
1178
1179 // used for testing of localhost to prevent wordpress issues with getting files from local server
1180 public function disable_localhost_url_check_for_development( $parsed_args ) {
1181 $parsed_args['reject_unsafe_urls'] = false;
1182
1183 return $parsed_args;
1184 }
1185
1186 /*
1187 * Check if current user is Agent or Manager, automatically redirect to latepoint dashboard instead of default WordPress admin
1188 */
1189 public function redirect_manager_and_agent_to_latepoint( $redirect_to, $request, $user ) {
1190 if ( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
1191 if ( $user->has_cap( 'edit_bookings' ) || $user->has_cap( 'manage_latepoint' ) ) {
1192 return OsRouterHelper::build_link( [ 'dashboard', 'index' ] );
1193 }
1194 }
1195
1196 return $redirect_to;
1197 }
1198
1199
1200 public function clear_old_activity_logs() {
1201 if ( OsSettingsHelper::is_on( 'should_clear_old_activity_log' ) ) {
1202 global $wpdb;
1203 $activity = new OsActivityModel();
1204
1205 $now_datetime = OsTimeHelper::now_datetime_object();
1206
1207 $cutoff = $now_datetime->modify( '-6 months' )->format( LATEPOINT_DATETIME_DB_FORMAT );
1208 $wpdb->query( $wpdb->prepare( 'DELETE FROM %i WHERE `created_at` < %s', [ esc_sql( $activity->table_name ), $cutoff ] ) );
1209 }
1210 }
1211
1212 public function addon_activated( $addon_name, $addon_version ) {
1213 OsDatabaseHelper::check_db_version_for_addons();
1214 }
1215
1216 public function addon_deactivated( $addon_name, $addon_version ) {
1217 OsDatabaseHelper::delete_addon_info( $addon_name, $addon_version );
1218 }
1219
1220
1221 public function on_deactivate() {
1222 wp_clear_scheduled_hook( 'latepoint_check_if_addons_update_available' );
1223 wp_clear_scheduled_hook( 'latepoint_clear_old_activity_logs' );
1224 }
1225
1226 function on_activate() {
1227 OsRolesHelper::register_roles_in_wp();
1228
1229 if ( ! wp_next_scheduled( 'latepoint_check_if_addons_update_available' ) ) {
1230 wp_schedule_event( time(), 'daily', 'latepoint_check_if_addons_update_available' );
1231 }
1232
1233 if ( ! wp_next_scheduled( 'latepoint_clear_old_activity_logs' ) ) {
1234 wp_schedule_event( time(), 'daily', 'latepoint_clear_old_activity_logs' );
1235 }
1236
1237 // if wizard has not been visited yet - redirect to it
1238 if ( ! get_option( 'latepoint_wizard_visited', false ) ) {
1239 add_option( 'latepoint_redirect_to_wizard', true );
1240 }
1241
1242 // create default location
1243 OsLocationHelper::get_default_location();
1244
1245 # create default pages if not existing (customer cabinet)
1246 OsPagesHelper::create_predefined_pages();
1247
1248 do_action( 'latepoint_on_activate', 'latepoint', $this->version );
1249 }
1250
1251 function redirect_after_activation() {
1252 if ( get_option( 'latepoint_redirect_to_wizard', false ) ) {
1253 delete_option( 'latepoint_redirect_to_wizard' );
1254 if ( ! isset( $_GET['activate-multi'] ) ) {
1255 wp_redirect( OsRouterHelper::build_link( OsRouterHelper::build_route_name( 'wizard', 'setup' ) ) );
1256 }
1257 } elseif ( get_option( 'latepoint_show_version_5_modal', false ) ) {
1258 delete_option( 'latepoint_show_version_5_modal' );
1259 if ( ! isset( $_GET['activate-multi'] ) ) {
1260 wp_redirect( OsRouterHelper::build_link( OsRouterHelper::build_route_name( 'settings', 'version_5_intro' ) ) );
1261 }
1262 }
1263 }
1264
1265 public function front_route_parse_request( $wp ) {
1266 if ( isset( $wp->query_vars['latepoint_is_custom_route'] ) ) {
1267 if ( isset( $wp->query_vars['route_name'] ) ) {
1268 $this->route_call();
1269 }
1270 }
1271 }
1272
1273 public function front_route_query_vars( $query_vars ) {
1274 $query_vars[] = 'latepoint_booking_id';
1275 $query_vars[] = 'latepoint_is_custom_route';
1276 $query_vars[] = 'route_name';
1277
1278 return $query_vars;
1279 }
1280
1281 public function route_call() {
1282 $route_name = OsRouterHelper::get_request_param( 'route_name', OsRouterHelper::build_route_name( 'dashboard', 'index' ) );
1283 OsRouterHelper::call_by_route_name( $route_name, OsRouterHelper::get_request_param( 'return_format', 'html' ) );
1284 }
1285
1286 public function public_route_call() {
1287 OsRouterHelper::call_by_route_name( OsRouterHelper::build_route_name( 'steps', 'start_instant' ), OsRouterHelper::get_request_param( 'return_format', 'html' ) );
1288 }
1289
1290 public function pre_route_call() {
1291 if ( OsRouterHelper::get_request_param( 'pre_route' ) ) {
1292 $this->route_call();
1293 }
1294 }
1295
1296
1297 /**
1298 * Init LatePoint when WordPress Initialises.
1299 */
1300 public function init() {
1301 OsAuthHelper::set_current_user();
1302 OsStepsHelper::init_step_actions();
1303 OsSettingsHelper::run_autoload();
1304 $this->register_post_types();
1305 $this->register_shortcodes();
1306 // Set up localisation.
1307 $this->load_plugin_textdomain();
1308 do_action( 'latepoint_init' );
1309 add_filter( 'http_request_host_is_external', '__return_true' );
1310
1311 OsBlockHelper::register_blocks();
1312 }
1313
1314 public function init_widgets() {
1315 OsElementorHelper::init();
1316 OsBricksHelper::init();
1317 }
1318
1319 public function load_plugin_textdomain() {
1320 load_plugin_textdomain( 'latepoint', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
1321 }
1322
1323
1324 /**
1325 * Register a custom menu page.
1326 */
1327 function init_menus() {
1328 // link for admins
1329 add_menu_page(
1330 __( 'LatePoint', 'latepoint' ),
1331 __( 'LatePoint', 'latepoint' ),
1332 OsAuthHelper::get_current_user()->wp_capability,
1333 'latepoint',
1334 [ $this, 'route_call' ],
1335 'none'
1336 );
1337 }
1338
1339
1340 function add_latepoint_link_to_admin_bar( $wp_admin_bar ) {
1341 if ( OsAuthHelper::get_current_user()->has_backend_access() ) {
1342 // build link depending on who is logged in
1343 $args = [
1344 'id' => 'latepoint_top_link',
1345 'title' => '<span class="latepoint-icon latepoint-icon-lp-logo" style="margin-right: 7px;"></span><span style="">' . __( 'LatePoint', 'latepoint' ) . '</span>',
1346 'href' => OsRouterHelper::build_link( [ 'dashboard', 'index' ] ),
1347 'meta' => array( 'class' => '' ),
1348 ];
1349 $wp_admin_bar->add_node( $args );
1350 }
1351 }
1352
1353
1354 /**
1355 * Register shortcodes
1356 */
1357 public function register_shortcodes() {
1358 add_shortcode( 'latepoint_book_button', array( 'OsShortcodesHelper', 'shortcode_latepoint_book_button' ) );
1359 add_shortcode( 'latepoint_book_form', array( 'OsShortcodesHelper', 'shortcode_latepoint_book_form' ) );
1360 add_shortcode( 'latepoint_customer_dashboard', array( 'OsShortcodesHelper', 'shortcode_latepoint_customer_dashboard' ) );
1361 add_shortcode( 'latepoint_customer_login', array( 'OsShortcodesHelper', 'shortcode_latepoint_customer_login' ) );
1362 add_shortcode( 'latepoint_resources', array( 'OsShortcodesHelper', 'shortcode_latepoint_resources' ) );
1363 add_shortcode( 'latepoint_calendar', array( 'OsShortcodesHelper', 'shortcode_latepoint_calendar' ) );
1364 }
1365
1366 /*
1367
1368 SHORTCODES
1369
1370 */
1371
1372
1373 public function setup_environment() {
1374 if ( ! current_theme_supports( 'post-thumbnails' ) ) {
1375 add_theme_support( 'post-thumbnails' );
1376 }
1377 add_post_type_support( LATEPOINT_AGENT_POST_TYPE, 'thumbnail' );
1378 add_post_type_support( LATEPOINT_SERVICE_POST_TYPE, 'thumbnail' );
1379 add_post_type_support( LATEPOINT_CUSTOMER_POST_TYPE, 'thumbnail' );
1380 }
1381
1382
1383 public function create_required_tables() {
1384 OsDatabaseHelper::run_setup();
1385 }
1386
1387
1388 /**
1389 * Register core post types.
1390 */
1391 public function register_post_types() {
1392 }
1393
1394
1395 /**
1396 * Register scripts and styles - FRONT
1397 */
1398 public function load_front_scripts_and_styles() {
1399 $localized_vars = [
1400 'route_action' => 'latepoint_route_call',
1401 'response_status' => [
1402 'success' => 'success',
1403 'error' => 'error',
1404 ],
1405 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1406 'time_pick_style' => OsStepsHelper::get_time_pick_style(),
1407 'string_today' => __( 'Today', 'latepoint' ),
1408 'reload_booking_form_summary_route' => OsRouterHelper::build_route_name( 'steps', 'reload_booking_form_summary_panel' ),
1409 'time_system' => OsTimeHelper::get_time_system(),
1410 'msg_not_available' => __( 'Not Available', 'latepoint' ),
1411 'booking_button_route' => OsRouterHelper::build_route_name( 'steps', 'start' ),
1412 'remove_cart_item_route' => OsRouterHelper::build_route_name( 'carts', 'remove_item_from_cart' ),
1413 'show_booking_end_time' => ( OsSettingsHelper::is_on( 'show_booking_end_time' ) ) ? 'yes' : 'no',
1414 'customer_dashboard_url' => OsSettingsHelper::get_customer_dashboard_url( true ),
1415 'demo_mode' => OsSettingsHelper::is_env_demo(),
1416 'cancel_booking_prompt' => __( 'Are you sure you want to cancel this appointment?', 'latepoint' ),
1417 'single_space_message' => __( 'Space Available', 'latepoint' ),
1418 'many_spaces_message' => __( 'Spaces Available', 'latepoint' ),
1419 'body_font_family' => '"latepoint", -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif ',
1420 'headings_font_family' => '"latepoint", -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif ',
1421 'currency_symbol_before' => OsSettingsHelper::get_settings_value( 'currency_symbol_before', '' ),
1422 'currency_symbol_after' => OsSettingsHelper::get_settings_value( 'currency_symbol_after', '' ),
1423 'thousand_separator' => OsSettingsHelper::get_settings_value( 'thousand_separator', ',' ),
1424 'decimal_separator' => OsSettingsHelper::get_settings_value( 'decimal_separator', '.' ),
1425 'number_of_decimals' => OsSettingsHelper::get_settings_value( 'number_of_decimals', '2' ),
1426 'included_phone_countries' => wp_json_encode( OsSettingsHelper::get_included_phone_countries() ),
1427 'default_phone_country' => OsSettingsHelper::get_default_phone_country(),
1428 'is_timezone_selected' => OsTimeHelper::is_timezone_saved_in_session(),
1429 'start_from_order_intent_route' => OsRouterHelper::build_route_name( 'steps', 'start_from_order_intent' ),
1430 'start_from_order_intent_key' => OsRouterHelper::get_request_param( 'latepoint_order_intent_key' ) ? OsRouterHelper::get_request_param( 'latepoint_order_intent_key' ) : '',
1431 'is_enabled_show_dial_code_with_flag' => OsSettingsHelper::is_enabled_show_dial_code_with_flag(),
1432 'mask_phone_number_fields' => OsSettingsHelper::is_on( 'mask_phone_number_fields', LATEPOINT_VALUE_ON ),
1433 'msg_validation_presence' => __( 'can not be blank', 'latepoint' ),
1434 'msg_validation_presence_checkbox' => __( 'has to be checked', 'latepoint' ),
1435 'msg_validation_invalid' => __( 'is invalid', 'latepoint' ),
1436 'msg_minutes_suffix' => __( ' minutes', 'latepoint' ),
1437 'is_stripe_connect_enabled' => OsPaymentsHelper::is_payment_processor_enabled( OsStripeConnectHelper::$processor_code ),
1438 'check_order_intent_bookable_route' => OsRouterHelper::build_route_name( 'steps', 'check_order_intent_bookable' ),
1439 'generate_timeslots_for_day_route' => OsRouterHelper::build_route_name( 'steps', 'generate_timeslots_for_day' ),
1440 'payment_environment' => OsSettingsHelper::get_payments_environment(),
1441 'style_border_radius' => OsSettingsHelper::get_booking_form_border_radius(),
1442 'datepicker_timeslot_selected_label' => __( 'Selected', 'latepoint' ),
1443 'invoices_payment_form_route' => OsRouterHelper::build_route_name( 'invoices', 'payment_form' ),
1444 'invoices_summary_before_payment_route' => OsRouterHelper::build_route_name( 'invoices', 'summary_before_payment' ),
1445 'reset_presets_when_adding_new_item' => OsSettingsHelper::is_on( 'reset_presets_when_adding_new_item' ),
1446 ];
1447
1448 $localized_vars['start_from_transaction_access_key'] = '';
1449 if ( OsRouterHelper::get_request_param( 'latepoint_transaction_intent_key' ) ) {
1450 $invoice = OsInvoicesHelper::get_invoice_by_transaction_intent_key( OsRouterHelper::get_request_param( 'latepoint_transaction_intent_key' ) );
1451 if ( $invoice ) {
1452 $localized_vars['start_from_transaction_access_key'] = $invoice->access_key;
1453 }
1454 }
1455
1456 if ( OsPaymentsHelper::is_payment_processor_enabled( OsStripeConnectHelper::$processor_code ) ) {
1457 $localized_vars['stripe_connect_key'] = OsStripeConnectHelper::get_connect_publishable_key();
1458 $localized_vars['stripe_connected_account_id'] = OsStripeConnectHelper::get_connect_account_id();
1459 }
1460 $localized_vars['stripe_connect_route_create_payment_intent'] = OsRouterHelper::build_route_name( 'stripe_connect', 'create_payment_intent' );
1461 $localized_vars['stripe_connect_route_create_payment_intent_for_transaction_intent'] = OsRouterHelper::build_route_name( 'stripe_connect', 'create_payment_intent_for_transaction' );
1462
1463 // Stylesheets
1464 wp_enqueue_style( 'latepoint-main-front', $this->public_stylesheets() . 'front.css', false, $this->version );
1465
1466 // add styles from options if gutenberg blocks exists
1467 OsBlockHelper::add_block_styles_to_page();
1468
1469 // Javscripts
1470
1471 // Addon scripts and styles
1472 do_action( 'latepoint_wp_enqueue_scripts' );
1473
1474 if ( OsPaymentsHelper::is_payment_processor_enabled( OsStripeConnectHelper::$processor_code ) ) {
1475 wp_enqueue_script( 'stripe', 'https://js.stripe.com/v3/', false, null );
1476 }
1477
1478 wp_register_script( 'latepoint-vendor-front', $this->public_javascripts() . 'vendor-front.js', [ 'jquery' ], $this->version );
1479 wp_register_script(
1480 'latepoint-main-front',
1481 $this->public_javascripts() . 'front.js',
1482 [
1483 'jquery',
1484 'latepoint-vendor-front',
1485 'wp-i18n',
1486 ],
1487 $this->version
1488 );
1489
1490
1491 $localized_vars = apply_filters( 'latepoint_localized_vars_front', $localized_vars );
1492
1493 wp_localize_script( 'latepoint-main-front', 'latepoint_helper', $localized_vars );
1494 wp_enqueue_script( 'latepoint-main-front' );
1495
1496
1497 $latepoint_css_variables = OsStylesHelper::generate_css_variables();
1498 wp_add_inline_style( 'latepoint-main-front', $latepoint_css_variables );
1499 }
1500
1501 public function add_admin_body_class( $classes ) {
1502 if ( ( is_admin() ) && isset( $_GET['page'] ) && $_GET['page'] == 'latepoint' ) {
1503 $classes = $classes . ' latepoint-admin latepoint';
1504 }
1505
1506 return $classes;
1507 }
1508
1509 public function add_body_class( $classes ) {
1510 $classes[] = 'latepoint';
1511
1512 return $classes;
1513 }
1514
1515
1516 /**
1517 * Register admin scripts and styles - ADMIN
1518 */
1519 public function load_admin_scripts_and_styles() {
1520 // Stylesheets
1521 wp_enqueue_style( 'latepoint-blocks-editor', LatePoint::plugin_url() . 'blocks/assets/css/editor-styles.css', array( 'wp-edit-blocks' ), $this->version );
1522 wp_enqueue_style( 'latepoint-main-admin', $this->public_stylesheets() . 'admin.css', false, $this->version );
1523
1524 // Javscripts
1525 wp_enqueue_media();
1526
1527
1528 wp_enqueue_script( 'latepoint-vendor-admin', $this->public_javascripts() . 'vendor-admin.js', [ 'jquery' ], $this->version );
1529 wp_enqueue_script(
1530 'latepoint-main-admin',
1531 $this->public_javascripts() . 'admin.js',
1532 [
1533 'jquery',
1534 'latepoint-vendor-admin',
1535 'wp-i18n',
1536 ],
1537 $this->version
1538 );
1539
1540
1541 do_action( 'latepoint_admin_enqueue_scripts' );
1542
1543 $localized_vars = [
1544 'route_action' => 'latepoint_route_call',
1545 'response_status' => [
1546 'success' => 'success',
1547 'error' => 'error',
1548 ],
1549 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1550 'value_all' => LATEPOINT_ALL,
1551 'value_on' => LATEPOINT_VALUE_ON,
1552 'value_off' => LATEPOINT_VALUE_OFF,
1553 'body_font_family' => '"latepoint", -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif ',
1554 'headings_font_family' => '"latepoint", -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif ',
1555 'wp_locale' => get_locale(),
1556 'string_today' => __( 'Today', 'latepoint' ),
1557 'click_to_copy_done' => __( 'Copied', 'latepoint' ),
1558 'click_to_copy_prompt' => __( 'Just click to copy', 'latepoint' ),
1559 'approve_confirm' => __( 'Are you sure you want to approve this booking?', 'latepoint' ),
1560 'reject_confirm' => __( 'Are you sure you want to reject this booking?', 'latepoint' ),
1561 'time_system' => OsTimeHelper::get_time_system(),
1562 'msg_not_available' => __( 'Not Available', 'latepoint' ),
1563 'msg_addon_activated' => __( 'Active', 'latepoint' ),
1564 'datepicker_timeslot_selected_label' => __( 'Selected', 'latepoint' ),
1565 'string_minutes' => __( 'minutes', 'latepoint' ),
1566 'single_space_message' => __( 'Space Available', 'latepoint' ),
1567 'many_spaces_message' => __( 'Spaces Available', 'latepoint' ),
1568 'currency_symbol_before' => OsSettingsHelper::get_settings_value( 'currency_symbol_before', '' ),
1569 'currency_symbol_after' => OsSettingsHelper::get_settings_value( 'currency_symbol_after', '' ),
1570 'thousand_separator' => OsSettingsHelper::get_settings_value( 'thousand_separator', ',' ),
1571 'decimal_separator' => OsSettingsHelper::get_settings_value( 'decimal_separator', '.' ),
1572 'number_of_decimals' => OsSettingsHelper::get_settings_value( 'number_of_decimals', '2' ),
1573 'included_phone_countries' => wp_json_encode( OsSettingsHelper::get_included_phone_countries() ),
1574 'default_phone_country' => OsSettingsHelper::get_default_phone_country(),
1575 'date_format' => OsSettingsHelper::get_date_format(),
1576 'date_format_for_js' => OsSettingsHelper::get_date_format_for_js(),
1577 'is_enabled_show_dial_code_with_flag' => OsSettingsHelper::is_enabled_show_dial_code_with_flag(),
1578 'mask_phone_number_fields' => OsSettingsHelper::is_on( 'mask_phone_number_fields', LATEPOINT_VALUE_ON ),
1579 'msg_validation_presence' => __( 'can not be blank', 'latepoint' ),
1580 'msg_validation_presence_checkbox' => __( 'has to be checked', 'latepoint' ),
1581 'msg_validation_invalid' => __( 'is invalid', 'latepoint' ),
1582 'msg_minutes_suffix' => __( ' minutes', 'latepoint' ),
1583 'order_item_variant_booking' => LATEPOINT_ITEM_VARIANT_BOOKING,
1584 'order_item_variant_bundle' => LATEPOINT_ITEM_VARIANT_BUNDLE,
1585 ];
1586
1587 // Add block related variables
1588 $localized_vars = array_merge( $localized_vars, OsBlockHelper::localized_vars_for_blocks() );
1589
1590 /**
1591 * Array of localized variables to be available in latepoint_helper object in admin
1592 *
1593 * @param {array} $localized_vars The default array being filtered
1594 * @returns {array} The filtered array of localized variables
1595 *
1596 * @since 5.0.0
1597 * @hook latepoint_localized_vars_admin
1598 *
1599 */
1600 $localized_vars = apply_filters( 'latepoint_localized_vars_admin', $localized_vars );
1601
1602 wp_localize_script( 'latepoint-main-admin', 'latepoint_helper', $localized_vars );
1603
1604
1605 $latepoint_css_variables = OsStylesHelper::generate_css_variables();
1606 wp_add_inline_style( 'latepoint-main-admin', $latepoint_css_variables );
1607 }
1608 }
1609 endif;
1610
1611
1612 $LATEPOINT = new LatePoint();
1613