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