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