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