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