-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathameliabooking.php
More file actions
618 lines (498 loc) · 22.8 KB
/
Copy pathameliabooking.php
File metadata and controls
618 lines (498 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
<?php
/*
Plugin Name: Amelia
Plugin URI: https://wpamelia.com/
Description: Amelia is a simple yet powerful automated booking specialist, working 24/7 to make sure your customers can make appointments and events even while you sleep!
Version: 8.1
Author: TMS
Author URI: https://tmsproducts.io/
Text Domain: wpamelia
Domain Path: /languages
*/
namespace AmeliaBooking;
use AmeliaBooking\Domain\Services\Settings\SettingsService;
use AmeliaBooking\Infrastructure\Common\Container;
use AmeliaBooking\Infrastructure\Routes\Routes;
use AmeliaBooking\Infrastructure\Services\Payment\SquareService;
use AmeliaBooking\Infrastructure\WP\ButtonService\ButtonService;
use AmeliaBooking\Infrastructure\WP\config\Menu;
use AmeliaBooking\Infrastructure\WP\Elementor\ElementorBlock;
use AmeliaBooking\Infrastructure\WP\ErrorService\ErrorService;
use AmeliaBooking\Infrastructure\WP\GutenbergBlock\AmeliaBookingGutenbergBlock;
use AmeliaBooking\Infrastructure\WP\GutenbergBlock\AmeliaStepBookingGutenbergBlock;
use AmeliaBooking\Infrastructure\WP\GutenbergBlock\AmeliaCatalogBookingGutenbergBlock;
use AmeliaBooking\Infrastructure\WP\GutenbergBlock\AmeliaCatalogGutenbergBlock;
use AmeliaBooking\Infrastructure\WP\GutenbergBlock\AmeliaCustomerCabinetGutenbergBlock;
use AmeliaBooking\Infrastructure\WP\GutenbergBlock\AmeliaEmployeeCabinetGutenbergBlock;
use AmeliaBooking\Infrastructure\WP\GutenbergBlock\AmeliaEventsGutenbergBlock;
use AmeliaBooking\Infrastructure\WP\GutenbergBlock\AmeliaEventsListBookingGutenbergBlock;
use AmeliaBooking\Infrastructure\WP\GutenbergBlock\AmeliaEventsCalendarBookingGutenbergBlock;
use AmeliaBooking\Infrastructure\WP\GutenbergBlock\AmeliaSearchGutenbergBlock;
use AmeliaBooking\Infrastructure\WP\Integrations\WooCommerce\WooCommerceService;
use AmeliaBooking\Infrastructure\WP\SettingsService\SettingsStorage;
use AmeliaBooking\Infrastructure\WP\Translations\BackendStrings;
use AmeliaBooking\Infrastructure\WP\UserRoles\UserRoles;
use AmeliaBooking\Infrastructure\WP\WPMenu\Submenu;
use AmeliaBooking\Infrastructure\WP\WPMenu\SubmenuPageHandler;
use Exception;
use Interop\Container\Exception\ContainerException;
use Slim\App;
// No direct access
defined('ABSPATH') or die('No script kiddies please!');
// Const for path root
if (!defined('AMELIA_PATH')) {
define('AMELIA_PATH', __DIR__);
}
// Const for uploads path
if (!defined('AMELIA_UPLOADS_PATH')) {
$uploadDir = wp_upload_dir();
define('AMELIA_UPLOADS_PATH', $uploadDir['basedir']);
}
// Const for uploads url
if (!defined('AMELIA_UPLOADS_URL')) {
$uploadUrl = wp_upload_dir();
define('AMELIA_UPLOADS_URL', set_url_scheme($uploadUrl['baseurl']));
}
// Const for uploads url
if (!defined('AMELIA_UPLOADS_FILES_URL')) {
define('AMELIA_UPLOADS_FILES_URL', AMELIA_UPLOADS_URL . '/amelia/files/');
}
// Const for uploads files path
if (!defined('AMELIA_UPLOADS_FILES_PATH')) {
define('AMELIA_UPLOADS_FILES_PATH', AMELIA_UPLOADS_PATH . '/amelia/files/');
}
// Const for uploads files path
if (!defined('AMELIA_UPLOADS_FILES_PATH_USE')) {
define('AMELIA_UPLOADS_FILES_PATH_USE', true);
}
// Const for URL root
if (!defined('AMELIA_URL')) {
define('AMELIA_URL', plugin_dir_url(__FILE__));
}
if (!defined('AMELIA_HOME_URL')) {
define('AMELIA_HOME_URL', get_home_url());
}
// Const for URL Actions identifier
if (!defined('AMELIA_ACTION_SLUG')) {
define('AMELIA_ACTION_SLUG', 'action=wpamelia_api&call=');
}
// Const for URL Actions identifier
if (!defined('AMELIA_ACTION_URL')) {
define('AMELIA_ACTION_URL', admin_url('admin-ajax.php', '') . '?' . AMELIA_ACTION_SLUG);
}
// Const for URL Actions identifier
if (!defined('AMELIA_PAGE_URL')) {
define('AMELIA_PAGE_URL', get_site_url() . '/wp-admin/admin.php?page=');
}
// Const for URL Actions identifier
if (!defined('AMELIA_LOGIN_URL')) {
define('AMELIA_LOGIN_URL', get_site_url() . '/wp-login.php?redirect_to=');
}
// Const for Amelia version
if (!defined('AMELIA_VERSION')) {
define('AMELIA_VERSION', '8.1');
}
// Const for site URL
if (!defined('AMELIA_SITE_URL')) {
define('AMELIA_SITE_URL', get_site_url());
}
// Const for plugin basename
if (!defined('AMELIA_PLUGIN_SLUG')) {
define('AMELIA_PLUGIN_SLUG', plugin_basename(__FILE__));
}
// Const for Amelia SMS API
if (!defined('AMELIA_SMS_API_URL')) {
define('AMELIA_SMS_API_URL', 'https://smsapi.wpamelia.com/');
define('AMELIA_SMS_VENDOR_ID', 36082);
define('AMELIA_SMS_PRODUCT_ID_10', 595657);
define('AMELIA_SMS_PRODUCT_ID_20', 595658);
define('AMELIA_SMS_PRODUCT_ID_50', 595659);
define('AMELIA_SMS_PRODUCT_ID_100', 595660);
define('AMELIA_SMS_PRODUCT_ID_200', 595661);
define('AMELIA_SMS_PRODUCT_ID_500', 595662);
}
if (!defined('AMELIA_STORE_API_URL')) {
define('AMELIA_STORE_API_URL', 'https://store.tms-plugins.com/api/');
}
if (!defined('AMELIA_MIDDLEWARE_IS_SANDBOX')) {
define('AMELIA_MIDDLEWARE_IS_SANDBOX', false);
}
if (!defined('AMELIA_MIDDLEWARE_API_URL')) {
define('AMELIA_MIDDLEWARE_API_URL', 'https://middleware.wpamelia.com/');
}
if (!defined('AMELIA_DEV')) {
define('AMELIA_DEV', false);
}
if (!defined('AMELIA_NGROK_URL')) {
define('AMELIA_NGROK_URL', '97619f3954de.ngrok.app');
}
require_once AMELIA_PATH . '/vendor/autoload.php';
/**
* @noinspection AutoloadingIssuesInspection
*
* Class Plugin
*
* @package AmeliaBooking
*
* @phpcs:ignoreFile
* @SuppressWarnings(PHPMD)
*/
class Plugin
{
/**
* API Call
*
* @throws \InvalidArgumentException
*/
public static function wpAmeliaApiCall()
{
try {
/** @var Container $container */
$container = require AMELIA_PATH . '/src/Infrastructure/ContainerConfig/container.php';
$app = new App($container);
// Initialize all API routes
Routes::routes($app, $container);
$app->run();
exit();
} catch (Exception $e) {
echo 'ERROR: ' . esc_html($e->getMessage());
}
}
static function square_weekly_token_refresh( $schedules ) {
$schedules['weekly'] = array(
'interval' => 604800,
'display' => __('Add weekly cron to refresh square access token every 7 days')
);
return $schedules;
}
/**
* Initialize the plugin
*/
public static function init()
{
$settingsService = new SettingsService(new SettingsStorage());
self::weglotConflict($settingsService, true);
// Const for path root
if (!defined('AMELIA_LOCALE')) {
define('AMELIA_LOCALE', get_user_locale());
}
load_plugin_textdomain('wpamelia', false, plugin_basename(__DIR__) . '/languages/' . AMELIA_LOCALE . '/');
self::weglotConflict($settingsService, false);
if (WooCommerceService::isEnabled()) {
if (!empty($settingsService->getCategorySettings('payments')['wc']['dashboard'])) {
add_filter('woocommerce_prevent_admin_access', '__return_false');
}
if (!empty($settingsService->getCategorySettings('payments')['wc']['enabled'])) {
try {
WooCommerceService::init($settingsService);
} catch (ContainerException $e) {
}
} else {
WooCommerceService::setContainer(require AMELIA_PATH . '/src/Infrastructure/ContainerConfig/container.php');
WooCommerceService::$settingsService = $settingsService;
add_filter('woocommerce_after_order_itemmeta', [WooCommerceService::class, 'orderItemMeta'], 10, 3);
}
}
if (!empty($settingsService->getCategorySettings('payments')['square']['enabled']) &&
!empty($settingsService->getCategorySettings('payments')['square']['accessToken'])) {
add_filter( 'cron_schedules', [self::class, 'square_weekly_token_refresh'] );
if ( ! wp_next_scheduled( 'amelia_square_access_token_refresh' ) ) {
wp_schedule_event( time(), 'weekly', 'amelia_square_access_token_refresh' );
}
/** @var Container $container */
$container = require AMELIA_PATH . '/src/Infrastructure/ContainerConfig/container.php';
/** @var SquareService $squareService */
$squareService = $container->get('infrastructure.payment.square.service');
add_action( 'amelia_square_access_token_refresh', [$squareService, 'refreshAccessToken'] );
}
$ameliaRole = UserRoles::getUserAmeliaRole(wp_get_current_user());
// Init menu if user is logged in with amelia role
if (in_array($ameliaRole, ['admin', 'manager', 'provider', 'customer'])) {
if ($ameliaRole === 'admin') {
ErrorService::setNotices();
}
// Add TinyMCE button for shortcode generator
ButtonService::renderButton();
// Add Gutenberg Block for shortcode generator
AmeliaStepBookingGutenbergBlock::init();
AmeliaCatalogBookingGutenbergBlock::init();
AmeliaBookingGutenbergBlock::init();
AmeliaSearchGutenbergBlock::init();
AmeliaCatalogGutenbergBlock::init();
AmeliaEventsGutenbergBlock::init();
AmeliaEventsListBookingGutenbergBlock::init();
AmeliaEventsCalendarBookingGutenbergBlock::init();
AmeliaCustomerCabinetGutenbergBlock::init();
AmeliaEmployeeCabinetGutenbergBlock::init();
add_filter('block_categories_all', array('AmeliaBooking\Plugin', 'addAmeliaBlockCategory'), 10, 2);
add_filter('learn-press/frontend-default-scripts', array('AmeliaBooking\Plugin', 'learnPressConflict'));
}
if (!is_admin()) {
add_filter('learn-press/frontend-default-scripts', array('AmeliaBooking\Plugin', 'learnPressConflict'));
add_shortcode('ameliabooking', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\BookingShortcodeService', 'shortcodeHandler'));
add_shortcode('ameliasearch', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\SearchShortcodeService', 'shortcodeHandler'));
add_shortcode('ameliacatalog', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\CatalogShortcodeService', 'shortcodeHandler'));
add_shortcode('ameliaevents', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\EventsShortcodeService', 'shortcodeHandler'));
add_shortcode('ameliaeventslistbooking', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\EventsListBookingShortcodeService', 'shortcodeHandler'));
add_shortcode('ameliaeventscalendarbooking', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\EventsCalendarBookingShortcodeService', 'shortcodeHandler'));
add_shortcode('ameliacustomerpanel', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\CabinetCustomerShortcodeService', 'shortcodeHandler'));
add_shortcode('ameliaemployeepanel', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\CabinetEmployeeShortcodeService', 'shortcodeHandler'));
add_shortcode('ameliastepbooking', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\StepBookingShortcodeService', 'shortcodeHandler'));
add_shortcode('ameliacatalogbooking', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\CatalogBookingShortcodeService', 'shortcodeHandler'));
}
if (defined('ELEMENTOR_VERSION')) {
ElementorBlock::get_instance();
}
require_once AMELIA_PATH . '/extensions/divi_amelia/divi_amelia.php';
require_once AMELIA_PATH . '/extensions/buddyboss-platform-addon/buddyboss-platform-addon.php';
}
/**
* Creating Amelia block category in Gutenberg
*/
public static function addAmeliaBlockCategory($categories, $post)
{
return array_merge(
array(
array(
'slug' => 'amelia-blocks',
'title' => 'Amelia',
),
),
$categories
);
}
/**
* Fix for conflict with Weglot plugin
* @param $settingsService
* @param $init
*/
public static function weglotConflict($settingsService, $init)
{
if (defined('AMELIA_LOCALE_FORCED') &&
AMELIA_LOCALE_FORCED &&
function_exists('weglot_get_current_language')
) {
try {
if ($init && !defined('AMELIA_LOCALE')) {
$weglotCurrentLanguage = weglot_get_current_language();
$ameliaUsedLanguages = array_flip($settingsService->getSetting('general', 'usedLanguages'));
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
global $locale;
$potentialLanguages = [];
foreach (wp_get_available_translations() as $key => $value) {
if (substr($key, 0, 2) === substr($weglotCurrentLanguage, 0, 2)) {
$potentialLanguages[] = $key;
}
}
foreach ($potentialLanguages as $potentialLanguage) {
if (array_key_exists($potentialLanguage, $ameliaUsedLanguages)) {
$locale = $potentialLanguage;
break;
}
}
} else {
global $locale;
$locale = AMELIA_LOCALE_FORCED;
}
} catch (\Exception $e) {
}
}
}
/**
* Fix for conflict with LearnPress plugin
*/
public static function learnPressConflict($data)
{
if (has_shortcode(get_post(get_the_ID())->post_content, 'ameliabooking') ||
has_shortcode(get_post(get_the_ID())->post_content, 'ameliacatalog') ||
has_shortcode(get_post(get_the_ID())->post_content, 'ameliasearch') ||
has_shortcode(get_post(get_the_ID())->post_content, 'ameliaevents') ||
has_shortcode(get_post(get_the_ID())->post_content, 'ameliacabinet') ||
has_shortcode(get_post(get_the_ID())->post_content, 'ameliaeventslistbooking') ||
has_shortcode(get_post(get_the_ID())->post_content, 'ameliaeventscalendarbooking') ||
has_shortcode(get_post(get_the_ID())->post_content, 'ameliastepbooking')
) {
return array();
} else {
return $data;
}
}
public static function initMenu()
{
$settingsService = new SettingsService(new SettingsStorage());
$menuItems = new Menu($settingsService);
// Init admin menu
$wpMenu = new Submenu(
new SubmenuPageHandler($settingsService),
$menuItems()
);
$wpMenu->addOptionsPages();
}
public static function adminInit()
{
$settingsService = new SettingsService(new SettingsStorage());
if (AMELIA_VERSION !== $settingsService->getSetting('activation', 'version')) {
$settingsService->setSetting('activation', 'version', AMELIA_VERSION);
require_once ABSPATH . 'wp-admin/includes/plugin.php';
deactivate_plugins(AMELIA_PLUGIN_SLUG);
activate_plugin(AMELIA_PLUGIN_SLUG);
}
}
/**
* @param $networkWide
*/
public static function activation($networkWide)
{
load_plugin_textdomain('wpamelia', false, plugin_basename(__DIR__) . '/languages/' . get_locale() . '/');
// Check PHP version
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50500) {
deactivate_plugins(AMELIA_PLUGIN_SLUG);
wp_die(
BackendStrings::getCommonStrings()['php_version_message'],
BackendStrings::getCommonStrings()['php_version_title'],
array('response' => 200, 'back_link' => TRUE)
);
}
//Network activation
if ($networkWide && function_exists('is_multisite') && is_multisite()) {
Infrastructure\WP\InstallActions\ActivationMultisite::init();
}
Infrastructure\WP\InstallActions\ActivationDatabaseHook::init();
}
/**
* @param $dirPath
*/
public static function deleteFolderContent($dirPath)
{
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
foreach ($files as $file) {
if (is_dir($file)) {
self::deleteFolderContent($file);
} else {
unlink($file);
}
}
}
/**
* @throws Domain\Common\Exceptions\InvalidArgumentException
*/
public static function deletion()
{
$settingsService = new SettingsService(new SettingsStorage());
if ($settingsService->getSetting('activation', 'deleteTables')) {
//Network deletion
if (function_exists('is_multisite') &&
is_multisite()
) {
Infrastructure\WP\InstallActions\DeletionMultisite::delete();
}
Infrastructure\WP\InstallActions\DeleteDatabaseHook::delete();
// Delete Roles
global $wp_roles;
$wp_roles->remove_role('wpamelia-customer');
$wp_roles->remove_role('wpamelia-provider');
$wp_roles->remove_role('wpamelia-manager');
// Delete Settings
delete_option('amelia_settings');
delete_option('amelia_stash');
delete_option('amelia_show_wpdt_promo');
// Delete Files
foreach (['/amelia/css', '/amelia/files/tmp', '/amelia/files', '/amelia'] as $path) {
if (is_dir(AMELIA_UPLOADS_PATH . $path)) {
self::deleteFolderContent(AMELIA_UPLOADS_PATH . $path);
rmdir(AMELIA_UPLOADS_PATH . $path);
}
}
}
}
public static function elementor_popup_notice(){
global $pagenow;
if ($pagenow == 'edit.php' &&
!empty($_REQUEST['post_type']) &&
$_REQUEST['post_type'] === 'elementor_library' &&
!empty($_REQUEST['tabs_group']) &&
$_REQUEST['tabs_group'] === 'popup'
) {
echo "<div class='notice notice-warning'>
<p>" . esc_html__(BackendStrings::getCommonStrings()['elementor_popup_notice']) . "</p>
</div>";
}
}
/**
* Show WPDT promo notice
**/
public static function wpdt_dashboard_promo()
{
$wpAmeliaPage = isset($_GET['page']) ? $_GET['page'] : '';
require_once AMELIA_PATH . '/extensions/wpdt/functions.php';
if( is_admin() && (strpos($wpAmeliaPage,'wpamelia-dashboard') !== false) &&
amelia_installed_plugins_wpdt_promotion() &&
get_option( 'amelia_show_wpdt_promo' ) == 'yes'
) {
include AMELIA_PATH . '/extensions/wpdt/promote_wpdt.php';
wp_enqueue_style('wdt-promo-css', AMELIA_URL . 'public/css/backend/promote_wpdt.css');
}
}
/**
* Remove WPDT promo notice
**/
public static function amelia_remove_wpdt_promo_notice()
{
update_option( 'amelia_show_wpdt_promo', 'no' );
echo json_encode( array("success") );
exit;
}
}
add_action('wp_ajax_amelia_remove_wpdt_promo_notice', array('AmeliaBooking\Plugin', 'amelia_remove_wpdt_promo_notice'));
add_action('admin_notices', array('AmeliaBooking\Plugin', 'elementor_popup_notice'));
add_action('admin_notices', array('AmeliaBooking\Plugin', 'wpdt_dashboard_promo'));
/** Redirect For Outlook Calendar */
if (is_admin()) {
add_action('wp_loaded', array('AmeliaBooking\Infrastructure\Services\Outlook\OutlookCalendarService', 'handleCallback'));
}
/** Isolate API calls */
add_action('wp_ajax_wpamelia_api', array('AmeliaBooking\Plugin', 'wpAmeliaApiCall'));
add_action('wp_ajax_nopriv_wpamelia_api', array('AmeliaBooking\Plugin', 'wpAmeliaApiCall'));
/** Init the plugin */
add_action('plugins_loaded', array('AmeliaBooking\Plugin', 'init'));
add_action('admin_init', array('AmeliaBooking\Plugin', 'adminInit'));
add_action('admin_menu', array('AmeliaBooking\Plugin', 'initMenu'));
/** Activation hooks */
register_activation_hook(__FILE__, array('AmeliaBooking\Plugin', 'activation'));
register_activation_hook(__FILE__, array('AmeliaBooking\Infrastructure\WP\InstallActions\ActivationRolesHook', 'init'));
register_activation_hook(__FILE__, array('AmeliaBooking\Infrastructure\WP\InstallActions\ActivationSettingsHook', 'init'));
register_uninstall_hook(__FILE__, array('AmeliaBooking\Plugin', 'deletion'));
/** Activation hook for new site on multisite setup */
add_action('wpmu_new_blog', array('AmeliaBooking\Infrastructure\WP\InstallActions\ActivationNewSiteMultisite', 'init'));
/** Define the API for updating checking */
add_filter('pre_set_site_transient_update_plugins', array('AmeliaBooking\Infrastructure\WP\InstallActions\AutoUpdateHook', 'checkUpdate'), 21, 1);
/** Define the alternative response for information checking */
add_filter('plugins_api', array('AmeliaBooking\Infrastructure\WP\InstallActions\AutoUpdateHook', 'checkInfo'), 20, 3);
/** Add a message for unavailable auto update if plugin is not activated */
add_action('in_plugin_update_message-' . AMELIA_PLUGIN_SLUG, array('AmeliaBooking\Infrastructure\WP\InstallActions\AutoUpdateHook', 'addMessageOnPluginsPage'));
/** Add error message on plugin update if plugin is not activated */
add_filter('upgrader_pre_download', array('AmeliaBooking\Infrastructure\WP\InstallActions\AutoUpdateHook', 'addMessageOnUpdate'), 10, 4);
add_filter('script_loader_tag', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\StepBookingShortcodeService', 'prepareScripts') , 10, 3);
add_filter('style_loader_tag', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\StepBookingShortcodeService', 'prepareStyles') , 10, 3);
add_filter('script_loader_tag', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\EventsListBookingShortcodeService', 'prepareScripts') , 10, 3);
add_filter('style_loader_tag', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\EventsListBookingShortcodeService', 'prepareStyles') , 10, 3);
add_filter('submenu_file', function($submenu_file) {
global $submenu;
if (!empty($submenu['amelia'])) {
foreach ($submenu['amelia'] as $index => $item) {
foreach ($item as $key => $value) {
if ($value === 'wpamelia-customize-new') {
unset($submenu['amelia'][$index]);
break 2;
}
}
}
}
return $submenu_file;
});
add_action('thrive_automator_init', array('AmeliaBooking\Infrastructure\WP\Integrations\ThriveAutomator\ThriveAutomatorService', 'init'));
add_action( 'wp_logout', array('AmeliaBooking\Infrastructure\WP\UserService\UserService', 'logoutAmeliaUser'));
add_action( 'profile_update', array('AmeliaBooking\Infrastructure\WP\UserService\UserService', 'updateAmeliaUser'), 10, 3);