| 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.34 |
| 7 |
Author: TMS |
| 8 |
Author URI: https://tmsproducts.io/ |
| 9 |
Text Domain: ameliabooking |
| 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.34'); |
| 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_DEV')) { |
| 137 |
define('AMELIA_DEV', false); |
| 138 |
} |
| 139 |
|
| 140 |
if (!defined('AMELIA_NGROK_URL')) { |
| 141 |
define('AMELIA_NGROK_URL', 'ce3ac66a70b5.ngrok-free.app'); |
| 142 |
} |
| 143 |
|
| 144 |
if (!defined('AMELIA_MAILCHIMP_CLIENT_ID')) { |
| 145 |
define('AMELIA_MAILCHIMP_CLIENT_ID', '459163389015'); |
| 146 |
} |
| 147 |
|
| 148 |
require_once AMELIA_PATH . '/vendor/autoload.php'; |
| 149 |
|
| 150 |
/** |
| 151 |
* @noinspection AutoloadingIssuesInspection |
| 152 |
* |
| 153 |
* Class Plugin |
| 154 |
* |
| 155 |
* @package AmeliaBooking |
| 156 |
* |
| 157 |
* @phpcs:ignoreFile |
| 158 |
* @SuppressWarnings(PHPMD) |
| 159 |
*/ |
| 160 |
class Plugin |
| 161 |
{ |
| 162 |
|
| 163 |
/** |
| 164 |
* API Call |
| 165 |
* |
| 166 |
* @throws \InvalidArgumentException |
| 167 |
*/ |
| 168 |
public static function wpAmeliaApiCall() |
| 169 |
{ |
| 170 |
try { |
| 171 |
/** @var Container $container */ |
| 172 |
$container = require AMELIA_PATH . '/src/Infrastructure/ContainerConfig/container.php'; |
| 173 |
|
| 174 |
$app = new App($container); |
| 175 |
|
| 176 |
// Initialize all API routes |
| 177 |
Routes::routes($app, $container); |
| 178 |
|
| 179 |
$app->run(); |
| 180 |
|
| 181 |
exit(); |
| 182 |
} catch (Exception $e) { |
| 183 |
echo 'ERROR: ' . esc_html($e->getMessage()); |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
static function square_weekly_token_refresh( $schedules ) { |
| 188 |
$schedules['weekly'] = array( |
| 189 |
'interval' => 604800, |
| 190 |
'display' => __('Add weekly cron to refresh square access token every 7 days') |
| 191 |
); |
| 192 |
return $schedules; |
| 193 |
} |
| 194 |
|
| 195 |
/** |
| 196 |
* Initialize the plugin |
| 197 |
*/ |
| 198 |
public static function init() |
| 199 |
{ |
| 200 |
$settingsService = new SettingsService(new SettingsStorage()); |
| 201 |
|
| 202 |
self::weglotConflict($settingsService, true); |
| 203 |
|
| 204 |
// Const for path root |
| 205 |
if (!defined('AMELIA_LOCALE')) { |
| 206 |
define('AMELIA_LOCALE', get_user_locale()); |
| 207 |
} |
| 208 |
|
| 209 |
load_plugin_textdomain('ameliabooking', false, plugin_basename(__DIR__) . '/languages/' . AMELIA_LOCALE . '/'); |
| 210 |
|
| 211 |
self::weglotConflict($settingsService, false); |
| 212 |
|
| 213 |
if (StarterWooCommerceService::isEnabled()) { |
| 214 |
if (!empty($settingsService->getCategorySettings('payments')['wc']['dashboard'])) { |
| 215 |
add_filter('woocommerce_prevent_admin_access', '__return_false'); |
| 216 |
} |
| 217 |
|
| 218 |
if (!empty($settingsService->getCategorySettings('payments')['wc']['enabled'])) { |
| 219 |
try { |
| 220 |
StarterWooCommerceService::init($settingsService); |
| 221 |
} catch (ContainerException $e) { |
| 222 |
} |
| 223 |
} else { |
| 224 |
StarterWooCommerceService::setContainer(require AMELIA_PATH . '/src/Infrastructure/ContainerConfig/container.php'); |
| 225 |
StarterWooCommerceService::$settingsService = $settingsService; |
| 226 |
|
| 227 |
add_filter('woocommerce_after_order_itemmeta', [StarterWooCommerceService::class, 'orderItemMeta'], 10, 3); |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
if (!empty($settingsService->getCategorySettings('payments')['square']['enabled']) && |
| 232 |
!empty($settingsService->getCategorySettings('payments')['square']['accessToken'])) { |
| 233 |
add_filter( 'cron_schedules', [self::class, 'square_weekly_token_refresh'] ); |
| 234 |
|
| 235 |
if ( ! wp_next_scheduled( 'amelia_square_access_token_refresh' ) ) { |
| 236 |
wp_schedule_event( time(), 'weekly', 'amelia_square_access_token_refresh' ); |
| 237 |
} |
| 238 |
|
| 239 |
/** @var Container $container */ |
| 240 |
$container = require AMELIA_PATH . '/src/Infrastructure/ContainerConfig/container.php'; |
| 241 |
|
| 242 |
/** @var SquareService $squareService */ |
| 243 |
$squareService = $container->get('infrastructure.payment.square.service'); |
| 244 |
|
| 245 |
add_action( 'amelia_square_access_token_refresh', [$squareService, 'refreshAccessToken'] ); |
| 246 |
} |
| 247 |
|
| 248 |
$ameliaRole = UserRoles::getUserAmeliaRole(wp_get_current_user()); |
| 249 |
|
| 250 |
// Init menu if user is logged in with amelia role |
| 251 |
if (in_array($ameliaRole, ['admin', 'manager', 'provider', 'customer'])) { |
| 252 |
if ($ameliaRole === 'admin') { |
| 253 |
ErrorService::setNotices(); |
| 254 |
} |
| 255 |
|
| 256 |
// Add TinyMCE button for shortcode generator |
| 257 |
ButtonService::renderButton(); |
| 258 |
|
| 259 |
// Add Gutenberg Block for shortcode generator |
| 260 |
AmeliaStepBookingGutenbergBlock::init(); |
| 261 |
AmeliaCatalogBookingGutenbergBlock::init(); |
| 262 |
AmeliaBookingGutenbergBlock::init(); |
| 263 |
AmeliaCatalogGutenbergBlock::init(); |
| 264 |
AmeliaEventsGutenbergBlock::init(); |
| 265 |
AmeliaEventsListBookingGutenbergBlock::init(); |
| 266 |
|
| 267 |
|
| 268 |
add_filter('block_categories_all', array('AmeliaBooking\Plugin', 'addAmeliaBlockCategory'), 10, 2); |
| 269 |
add_filter('learn-press/frontend-default-scripts', array('AmeliaBooking\Plugin', 'learnPressConflict')); |
| 270 |
} |
| 271 |
|
| 272 |
if (!is_admin()) { |
| 273 |
add_filter('learn-press/frontend-default-scripts', array('AmeliaBooking\Plugin', 'learnPressConflict')); |
| 274 |
add_shortcode('ameliabooking', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\BookingShortcodeService', 'shortcodeHandler')); |
| 275 |
add_shortcode('ameliacatalog', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\CatalogShortcodeService', 'shortcodeHandler')); |
| 276 |
add_shortcode('ameliaevents', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\EventsShortcodeService', 'shortcodeHandler')); |
| 277 |
add_shortcode('ameliaeventslistbooking', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\EventsListBookingShortcodeService', 'shortcodeHandler')); |
| 278 |
add_shortcode('ameliastepbooking', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\StepBookingShortcodeService', 'shortcodeHandler')); |
| 279 |
add_shortcode('ameliacatalogbooking', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\CatalogBookingShortcodeService', 'shortcodeHandler')); |
| 280 |
} |
| 281 |
|
| 282 |
if (defined('ELEMENTOR_VERSION')) { |
| 283 |
ElementorBlock::get_instance(); |
| 284 |
} |
| 285 |
|
| 286 |
require_once AMELIA_PATH . '/extensions/divi_amelia/divi_amelia.php'; |
| 287 |
|
| 288 |
|
| 289 |
} |
| 290 |
|
| 291 |
/** |
| 292 |
* Creating Amelia block category in Gutenberg |
| 293 |
*/ |
| 294 |
public static function addAmeliaBlockCategory($categories, $post) |
| 295 |
{ |
| 296 |
return array_merge( |
| 297 |
array( |
| 298 |
array( |
| 299 |
'slug' => 'amelia-blocks', |
| 300 |
'title' => 'Amelia', |
| 301 |
), |
| 302 |
), |
| 303 |
$categories |
| 304 |
); |
| 305 |
} |
| 306 |
|
| 307 |
/** |
| 308 |
* Fix for conflict with Weglot plugin |
| 309 |
* @param $settingsService |
| 310 |
* @param $init |
| 311 |
*/ |
| 312 |
public static function weglotConflict($settingsService, $init) |
| 313 |
{ |
| 314 |
if (defined('AMELIA_LOCALE_FORCED') && |
| 315 |
AMELIA_LOCALE_FORCED && |
| 316 |
function_exists('weglot_get_current_language') |
| 317 |
) { |
| 318 |
try { |
| 319 |
if ($init && !defined('AMELIA_LOCALE')) { |
| 320 |
$weglotCurrentLanguage = weglot_get_current_language(); |
| 321 |
|
| 322 |
$ameliaUsedLanguages = array_flip($settingsService->getSetting('general', 'usedLanguages')); |
| 323 |
|
| 324 |
require_once ABSPATH . 'wp-admin/includes/translation-install.php'; |
| 325 |
|
| 326 |
global $locale; |
| 327 |
|
| 328 |
$potentialLanguages = []; |
| 329 |
|
| 330 |
foreach (wp_get_available_translations() as $key => $value) { |
| 331 |
if (substr($key, 0, 2) === substr($weglotCurrentLanguage, 0, 2)) { |
| 332 |
$potentialLanguages[] = $key; |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
foreach ($potentialLanguages as $potentialLanguage) { |
| 337 |
if (array_key_exists($potentialLanguage, $ameliaUsedLanguages)) { |
| 338 |
$locale = $potentialLanguage; |
| 339 |
break; |
| 340 |
} |
| 341 |
} |
| 342 |
} else { |
| 343 |
global $locale; |
| 344 |
|
| 345 |
$locale = AMELIA_LOCALE_FORCED; |
| 346 |
} |
| 347 |
} catch (\Exception $e) { |
| 348 |
|
| 349 |
} |
| 350 |
} |
| 351 |
} |
| 352 |
|
| 353 |
/** |
| 354 |
* Fix for conflict with LearnPress plugin |
| 355 |
*/ |
| 356 |
public static function learnPressConflict($data) |
| 357 |
{ |
| 358 |
|
| 359 |
if (has_shortcode(get_post(get_the_ID())->post_content, 'ameliabooking') || |
| 360 |
has_shortcode(get_post(get_the_ID())->post_content, 'ameliacatalog') || |
| 361 |
has_shortcode(get_post(get_the_ID())->post_content, 'ameliaevents') || |
| 362 |
has_shortcode(get_post(get_the_ID())->post_content, 'ameliaeventslistbooking') || |
| 363 |
has_shortcode(get_post(get_the_ID())->post_content, 'ameliastepbooking') |
| 364 |
) { |
| 365 |
return array(); |
| 366 |
} else { |
| 367 |
return $data; |
| 368 |
} |
| 369 |
|
| 370 |
} |
| 371 |
|
| 372 |
public static function initMenu() |
| 373 |
{ |
| 374 |
$settingsService = new SettingsService(new SettingsStorage()); |
| 375 |
|
| 376 |
$menuItems = new Menu($settingsService); |
| 377 |
|
| 378 |
// Init admin menu |
| 379 |
$wpMenu = new Submenu( |
| 380 |
new SubmenuPageHandler($settingsService), |
| 381 |
$menuItems() |
| 382 |
); |
| 383 |
|
| 384 |
$wpMenu->addOptionsPages(); |
| 385 |
} |
| 386 |
|
| 387 |
public static function adminInit() |
| 388 |
{ |
| 389 |
$settingsService = new SettingsService(new SettingsStorage()); |
| 390 |
|
| 391 |
if (AMELIA_VERSION !== $settingsService->getSetting('activation', 'version')) { |
| 392 |
$settingsService->setSetting('activation', 'version', AMELIA_VERSION); |
| 393 |
|
| 394 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 395 |
|
| 396 |
deactivate_plugins(AMELIA_PLUGIN_SLUG); |
| 397 |
activate_plugin(AMELIA_PLUGIN_SLUG); |
| 398 |
} |
| 399 |
} |
| 400 |
|
| 401 |
/** |
| 402 |
* @param $networkWide |
| 403 |
*/ |
| 404 |
public static function activation($networkWide) |
| 405 |
{ |
| 406 |
load_plugin_textdomain('ameliabooking', false, plugin_basename(__DIR__) . '/languages/' . get_locale() . '/'); |
| 407 |
|
| 408 |
// Check PHP version |
| 409 |
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50500) { |
| 410 |
deactivate_plugins(AMELIA_PLUGIN_SLUG); |
| 411 |
wp_die( |
| 412 |
BackendStrings::getCommonStrings()['php_version_message'], |
| 413 |
BackendStrings::getCommonStrings()['php_version_title'], |
| 414 |
array('response' => 200, 'back_link' => TRUE) |
| 415 |
); |
| 416 |
} |
| 417 |
//Network activation |
| 418 |
if ($networkWide && function_exists('is_multisite') && is_multisite()) { |
| 419 |
Infrastructure\WP\InstallActions\ActivationMultisite::init(); |
| 420 |
} |
| 421 |
|
| 422 |
Infrastructure\WP\InstallActions\ActivationDatabaseHook::init(); |
| 423 |
} |
| 424 |
|
| 425 |
/** |
| 426 |
* @param $dirPath |
| 427 |
*/ |
| 428 |
public static function deleteFolderContent($dirPath) |
| 429 |
{ |
| 430 |
if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { |
| 431 |
$dirPath .= '/'; |
| 432 |
} |
| 433 |
|
| 434 |
$files = glob($dirPath . '*', GLOB_MARK); |
| 435 |
|
| 436 |
foreach ($files as $file) { |
| 437 |
if (is_dir($file)) { |
| 438 |
self::deleteFolderContent($file); |
| 439 |
} else { |
| 440 |
unlink($file); |
| 441 |
} |
| 442 |
} |
| 443 |
} |
| 444 |
|
| 445 |
/** |
| 446 |
* @throws Domain\Common\Exceptions\InvalidArgumentException |
| 447 |
*/ |
| 448 |
public static function deletion() |
| 449 |
{ |
| 450 |
$settingsService = new SettingsService(new SettingsStorage()); |
| 451 |
|
| 452 |
if ($settingsService->getSetting('activation', 'deleteTables')) { |
| 453 |
//Network deletion |
| 454 |
if (function_exists('is_multisite') && |
| 455 |
is_multisite() |
| 456 |
) { |
| 457 |
Infrastructure\WP\InstallActions\DeletionMultisite::delete(); |
| 458 |
} |
| 459 |
|
| 460 |
Infrastructure\WP\InstallActions\DeleteDatabaseHook::delete(); |
| 461 |
|
| 462 |
|
| 463 |
// Delete Roles |
| 464 |
global $wp_roles; |
| 465 |
|
| 466 |
$wp_roles->remove_role('wpamelia-customer'); |
| 467 |
$wp_roles->remove_role('wpamelia-provider'); |
| 468 |
$wp_roles->remove_role('wpamelia-manager'); |
| 469 |
|
| 470 |
|
| 471 |
// Delete Settings |
| 472 |
delete_option('amelia_settings'); |
| 473 |
delete_option('amelia_stash'); |
| 474 |
delete_option('amelia_show_wpdt_promo'); |
| 475 |
|
| 476 |
// Delete Files |
| 477 |
foreach (['/amelia/css', '/amelia/files/tmp', '/amelia/files', '/amelia'] as $path) { |
| 478 |
if (is_dir(AMELIA_UPLOADS_PATH . $path)) { |
| 479 |
self::deleteFolderContent(AMELIA_UPLOADS_PATH . $path); |
| 480 |
rmdir(AMELIA_UPLOADS_PATH . $path); |
| 481 |
} |
| 482 |
} |
| 483 |
} |
| 484 |
} |
| 485 |
|
| 486 |
|
| 487 |
public static function elementor_popup_notice(){ |
| 488 |
global $pagenow; |
| 489 |
if ($pagenow == 'edit.php' && |
| 490 |
!empty($_REQUEST['post_type']) && |
| 491 |
$_REQUEST['post_type'] === 'elementor_library' && |
| 492 |
!empty($_REQUEST['tabs_group']) && |
| 493 |
$_REQUEST['tabs_group'] === 'popup' |
| 494 |
) { |
| 495 |
echo "<div class='notice notice-warning'> |
| 496 |
<p>" . esc_html__(BackendStrings::getCommonStrings()['elementor_popup_notice']) . "</p> |
| 497 |
</div>"; |
| 498 |
} |
| 499 |
} |
| 500 |
|
| 501 |
/** |
| 502 |
* Show WPDT promo notice |
| 503 |
**/ |
| 504 |
public static function wpdt_dashboard_promo() |
| 505 |
{ |
| 506 |
$wpAmeliaPage = isset($_GET['page']) ? $_GET['page'] : ''; |
| 507 |
|
| 508 |
require_once AMELIA_PATH . '/extensions/wpdt/functions.php'; |
| 509 |
|
| 510 |
if( is_admin() && (strpos($wpAmeliaPage,'wpamelia-dashboard') !== false) && |
| 511 |
amelia_installed_plugins_wpdt_promotion() && |
| 512 |
get_option( 'amelia_show_wpdt_promo' ) == 'yes' |
| 513 |
) { |
| 514 |
include AMELIA_PATH . '/extensions/wpdt/promote_wpdt.php'; |
| 515 |
wp_enqueue_style('wdt-promo-css', AMELIA_URL . 'public/css/backend/promote_wpdt.css'); |
| 516 |
} |
| 517 |
} |
| 518 |
|
| 519 |
/** |
| 520 |
* Remove WPDT promo notice |
| 521 |
**/ |
| 522 |
public static function amelia_remove_wpdt_promo_notice() |
| 523 |
{ |
| 524 |
update_option( 'amelia_show_wpdt_promo', 'no' ); |
| 525 |
echo json_encode( array("success") ); |
| 526 |
exit; |
| 527 |
} |
| 528 |
|
| 529 |
} |
| 530 |
|
| 531 |
add_action('wp_ajax_amelia_remove_wpdt_promo_notice', array('AmeliaBooking\Plugin', 'amelia_remove_wpdt_promo_notice')); |
| 532 |
|
| 533 |
add_action('admin_notices', array('AmeliaBooking\Plugin', 'elementor_popup_notice')); |
| 534 |
add_action('admin_notices', array('AmeliaBooking\Plugin', 'wpdt_dashboard_promo')); |
| 535 |
|
| 536 |
/** Redirect For Outlook Calendar */ |
| 537 |
if (is_admin()) { |
| 538 |
add_action('wp_loaded', array('AmeliaBooking\Infrastructure\Services\Outlook\StarterOutlookCalendarService', 'handleCallback')); |
| 539 |
} |
| 540 |
|
| 541 |
/** Isolate API calls */ |
| 542 |
add_action('wp_ajax_wpamelia_api', array('AmeliaBooking\Plugin', 'wpAmeliaApiCall')); |
| 543 |
add_action('wp_ajax_nopriv_wpamelia_api', array('AmeliaBooking\Plugin', 'wpAmeliaApiCall')); |
| 544 |
|
| 545 |
/** Init the plugin */ |
| 546 |
add_action('plugins_loaded', array('AmeliaBooking\Plugin', 'init')); |
| 547 |
|
| 548 |
add_action('admin_init', array('AmeliaBooking\Plugin', 'adminInit')); |
| 549 |
|
| 550 |
add_action('admin_menu', array('AmeliaBooking\Plugin', 'initMenu')); |
| 551 |
|
| 552 |
/** Activation hooks */ |
| 553 |
register_activation_hook(__FILE__, array('AmeliaBooking\Plugin', 'activation')); |
| 554 |
register_activation_hook(__FILE__, array('AmeliaBooking\Infrastructure\WP\InstallActions\ActivationRolesHook', 'init')); |
| 555 |
register_activation_hook(__FILE__, array('AmeliaBooking\Infrastructure\WP\InstallActions\ActivationSettingsHook', 'init')); |
| 556 |
register_uninstall_hook(__FILE__, array('AmeliaBooking\Plugin', 'deletion')); |
| 557 |
|
| 558 |
/** Activation hook for new site on multisite setup */ |
| 559 |
add_action('wpmu_new_blog', array('AmeliaBooking\Infrastructure\WP\InstallActions\ActivationNewSiteMultisite', 'init')); |
| 560 |
|
| 561 |
/** Define the API for updating checking */ |
| 562 |
|
| 563 |
/** Define the alternative response for information checking */ |
| 564 |
|
| 565 |
/** Add a message for unavailable auto update if plugin is not activated */ |
| 566 |
|
| 567 |
/** Add error message on plugin update if plugin is not activated */ |
| 568 |
|
| 569 |
add_filter('script_loader_tag', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\StepBookingShortcodeService', 'prepareScripts') , 10, 3); |
| 570 |
add_filter('style_loader_tag', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\StepBookingShortcodeService', 'prepareStyles') , 10, 3); |
| 571 |
|
| 572 |
add_filter('script_loader_tag', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\EventsListBookingShortcodeService', 'prepareScripts') , 10, 3); |
| 573 |
add_filter('style_loader_tag', array('AmeliaBooking\Infrastructure\WP\ShortcodeService\EventsListBookingShortcodeService', 'prepareStyles') , 10, 3); |
| 574 |
|
| 575 |
add_filter('submenu_file', function($submenu_file) { |
| 576 |
global $submenu; |
| 577 |
|
| 578 |
if (!empty($submenu['amelia'])) { |
| 579 |
foreach ($submenu['amelia'] as $index => $item) { |
| 580 |
foreach ($item as $key => $value) { |
| 581 |
if ($value === 'wpamelia-customize-new') { |
| 582 |
unset($submenu['amelia'][$index]); |
| 583 |
|
| 584 |
break 2; |
| 585 |
} |
| 586 |
} |
| 587 |
} |
| 588 |
} |
| 589 |
|
| 590 |
return $submenu_file; |
| 591 |
}); |
| 592 |
|
| 593 |
|
| 594 |
add_action( 'wp_logout', array('AmeliaBooking\Infrastructure\WP\UserService\UserService', 'logoutAmeliaUser')); |
| 595 |
add_action( 'profile_update', array('AmeliaBooking\Infrastructure\WP\UserService\UserService', 'updateAmeliaUser'), 10, 3); |
| 596 |
add_action( 'deleted_user', array('AmeliaBooking\Infrastructure\WP\UserService\UserService', 'removeWPUserConnection'), 10, 1); |