SettingsStorage.php
426 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Infrastructure\WP\SettingsService; |
| 4 | |
| 5 | use AmeliaBooking\Application\Services\Location\AbstractCurrentLocation; |
| 6 | use AmeliaBooking\Domain\Services\DateTime\DateTimeService; |
| 7 | use AmeliaBooking\Domain\Services\Settings\SettingsStorageInterface; |
| 8 | use AmeliaBooking\Infrastructure\Licence; |
| 9 | |
| 10 | /** |
| 11 | * Class SettingsStorage |
| 12 | * |
| 13 | * @package AmeliaBooking\Infrastructure\WP\SettingsService |
| 14 | */ |
| 15 | class SettingsStorage implements SettingsStorageInterface |
| 16 | { |
| 17 | /** @var array|mixed */ |
| 18 | private $settingsCache; |
| 19 | |
| 20 | /** @var AbstractCurrentLocation */ |
| 21 | private $locationService; |
| 22 | |
| 23 | private static $wpSettings = [ |
| 24 | 'dateFormat' => 'date_format', |
| 25 | 'timeFormat' => 'time_format', |
| 26 | 'startOfWeek' => 'start_of_week', |
| 27 | 'timeZoneString' => 'timezone_string', |
| 28 | 'gmtOffset' => 'gmt_offset' |
| 29 | ]; |
| 30 | |
| 31 | /** |
| 32 | * SettingsStorage constructor. |
| 33 | */ |
| 34 | public function __construct() |
| 35 | { |
| 36 | $this->locationService = Licence\ApplicationService::getCurrentLocationService(); |
| 37 | |
| 38 | $this->settingsCache = self::getSavedSettings(); |
| 39 | |
| 40 | Licence\DataModifier::modifySettings($this->settingsCache); |
| 41 | |
| 42 | foreach (self::$wpSettings as $ameliaSetting => $wpSetting) { |
| 43 | $this->settingsCache['wordpress'][$ameliaSetting] = get_option($wpSetting); |
| 44 | } |
| 45 | |
| 46 | DateTimeService::setTimeZone($this->getAllSettings()); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @return array |
| 51 | */ |
| 52 | private function getSavedSettings() |
| 53 | { |
| 54 | return json_decode(get_option('amelia_settings'), true); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * @param $settingCategoryKey |
| 59 | * @param $settingKey |
| 60 | * |
| 61 | * @return mixed |
| 62 | */ |
| 63 | public function getSetting($settingCategoryKey, $settingKey) |
| 64 | { |
| 65 | return isset($this->settingsCache[$settingCategoryKey][$settingKey]) ? |
| 66 | $this->settingsCache[$settingCategoryKey][$settingKey] : null; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * @param $settingCategoryKey |
| 71 | * |
| 72 | * @return mixed |
| 73 | */ |
| 74 | public function getCategorySettings($settingCategoryKey) |
| 75 | { |
| 76 | return isset($this->settingsCache[$settingCategoryKey]) ? |
| 77 | $this->settingsCache[$settingCategoryKey] : null; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @return array|mixed|null |
| 82 | */ |
| 83 | public function getAllSettings() |
| 84 | { |
| 85 | $settings = []; |
| 86 | |
| 87 | if (null !== $this->settingsCache) { |
| 88 | foreach ((array)$this->settingsCache as $settingsCategoryName => $settingsCategory) { |
| 89 | if ($settingsCategoryName !== 'daysOff') { |
| 90 | foreach ((array)$settingsCategory as $settingName => $settingValue) { |
| 91 | $settings[$settingName] = $settingValue; |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | return $settings; |
| 97 | } |
| 98 | |
| 99 | return null; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * @return array|mixed|null |
| 104 | */ |
| 105 | public function getAllSettingsCategorized() |
| 106 | { |
| 107 | return isset($this->settingsCache) ? $this->settingsCache : null; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Return settings for frontend |
| 112 | * |
| 113 | * @return array|mixed |
| 114 | */ |
| 115 | public function getFrontendSettings() |
| 116 | { |
| 117 | $phoneCountryCode = $this->getSetting('general', 'phoneDefaultCountryCode'); |
| 118 | $ipLocateApyKey = $this->getSetting('general', 'ipLocateApiKey'); |
| 119 | |
| 120 | $capabilities = []; |
| 121 | $additionalCapabilities = []; |
| 122 | if (is_admin()) { |
| 123 | $currentScreenId = get_current_screen()->id; |
| 124 | $currentScreen = substr($currentScreenId, strrpos($currentScreenId, '-') + 1); |
| 125 | |
| 126 | $capabilities = [ |
| 127 | 'canRead' => current_user_can('amelia_read_' . $currentScreen), |
| 128 | 'canReadOthers' => current_user_can('amelia_read_others_' . $currentScreen), |
| 129 | 'canWrite' => current_user_can('amelia_write_' . $currentScreen), |
| 130 | 'canWriteOthers' => current_user_can('amelia_write_others_' . $currentScreen), |
| 131 | 'canDelete' => current_user_can('amelia_delete_' . $currentScreen), |
| 132 | 'canWriteStatus' => current_user_can('amelia_write_status_' . $currentScreen), |
| 133 | ]; |
| 134 | |
| 135 | $additionalCapabilities = [ |
| 136 | 'canWriteCustomers' => current_user_can('amelia_write_customers'), |
| 137 | ]; |
| 138 | } |
| 139 | |
| 140 | $wpUser = wp_get_current_user(); |
| 141 | |
| 142 | $userType = 'customer'; |
| 143 | |
| 144 | if (in_array('administrator', $wpUser->roles, true) || is_super_admin($wpUser->ID)) { |
| 145 | $userType = 'admin'; |
| 146 | } elseif (in_array('wpamelia-manager', $wpUser->roles, true)) { |
| 147 | $userType = 'manager'; |
| 148 | } elseif (in_array('wpamelia-provider', $wpUser->roles, true)) { |
| 149 | $userType = 'provider'; |
| 150 | } |
| 151 | |
| 152 | return [ |
| 153 | 'capabilities' => $capabilities, |
| 154 | 'additionalCapabilities' => $additionalCapabilities, |
| 155 | 'daysOff' => $this->getCategorySettings('daysOff'), |
| 156 | 'general' => [ |
| 157 | 'itemsPerPage' => $this->getSetting('general', 'itemsPerPage'), |
| 158 | 'itemsPerPageBackEnd' => $this->getSetting('general', 'itemsPerPageBackEnd'), |
| 159 | 'appointmentsPerPage' => $this->getSetting('general', 'appointmentsPerPage'), |
| 160 | 'eventsPerPage' => $this->getSetting('general', 'eventsPerPage'), |
| 161 | 'servicesPerPage' => $this->getSetting('general', 'servicesPerPage'), |
| 162 | 'customersFilterLimit' => $this->getSetting('general', 'customersFilterLimit'), |
| 163 | 'calendarEmployeesPreselected' => $this->getSetting('general', 'calendarEmployeesPreselected'), |
| 164 | 'phoneDefaultCountryCode' => $phoneCountryCode === 'auto' ? |
| 165 | $this->locationService->getCurrentLocationCountryIso($ipLocateApyKey) : $phoneCountryCode, |
| 166 | 'timeSlotLength' => $this->getSetting('general', 'timeSlotLength'), |
| 167 | 'serviceDurationAsSlot' => $this->getSetting('general', 'serviceDurationAsSlot'), |
| 168 | 'defaultAppointmentStatus' => $this->getSetting('general', 'defaultAppointmentStatus'), |
| 169 | 'gMapApiKey' => $this->getSetting('general', 'gMapApiKey'), |
| 170 | 'addToCalendar' => $this->getSetting('general', 'addToCalendar'), |
| 171 | 'requiredPhoneNumberField' => $this->getSetting('general', 'requiredPhoneNumberField'), |
| 172 | 'requiredEmailField' => $this->getSetting('general', 'requiredEmailField'), |
| 173 | 'numberOfDaysAvailableForBooking' => $this->getSetting('general', 'numberOfDaysAvailableForBooking'), |
| 174 | 'minimumTimeRequirementPriorToBooking' => |
| 175 | $this->getSetting('general', 'minimumTimeRequirementPriorToBooking'), |
| 176 | 'minimumTimeRequirementPriorToCanceling' => |
| 177 | $this->getSetting('general', 'minimumTimeRequirementPriorToCanceling'), |
| 178 | 'minimumTimeRequirementPriorToRescheduling' => |
| 179 | $this->getSetting('general', 'minimumTimeRequirementPriorToRescheduling'), |
| 180 | 'showClientTimeZone' => $this->getSetting('general', 'showClientTimeZone'), |
| 181 | 'redirectUrlAfterAppointment' => $this->getSetting('general', 'redirectUrlAfterAppointment'), |
| 182 | 'customFieldsUploadsPath' => $this->getSetting('general', 'customFieldsUploadsPath'), |
| 183 | 'customFieldsAllowedExtensions' => $this->getSetting('general', 'customFieldsAllowedExtensions'), |
| 184 | 'runInstantPostBookingActions' => $this->getSetting('general', 'runInstantPostBookingActions'), |
| 185 | 'sortingPackages' => $this->getSetting('general', 'sortingPackages'), |
| 186 | 'backLink' => $this->getSetting('general', 'backLink'), |
| 187 | 'sortingServices' => $this->getSetting('general', 'sortingServices'), |
| 188 | 'googleRecaptcha' => [ |
| 189 | 'enabled' => $this->getSetting('general', 'googleRecaptcha')['enabled'], |
| 190 | 'invisible' => $this->getSetting('general', 'googleRecaptcha')['invisible'], |
| 191 | 'siteKey' => $this->getSetting('general', 'googleRecaptcha')['siteKey'], |
| 192 | ], |
| 193 | 'usedLanguages' => $this->getSetting('general', 'usedLanguages'), |
| 194 | ], |
| 195 | 'googleMeet' => [ |
| 196 | 'enabled' => $this->getSetting('googleCalendar', 'enableGoogleMeet'), |
| 197 | ], |
| 198 | 'microsoftTeams' => [ |
| 199 | 'enabled' => $this->getSetting('outlookCalendar', 'enableMicrosoftTeams'), |
| 200 | ], |
| 201 | 'googleCalendar' => [ |
| 202 | 'enabled' => $this->getSetting('googleCalendar', 'clientID') && $this->getSetting('googleCalendar', 'clientSecret'), |
| 203 | 'googleMeetEnabled' => $this->getSetting('googleCalendar', 'enableGoogleMeet') |
| 204 | ], |
| 205 | 'outlookCalendar' => [ |
| 206 | 'enabled' => $this->getSetting('outlookCalendar', 'clientID') && $this->getSetting('outlookCalendar', 'clientSecret'), |
| 207 | 'microsoftTeamsEnabled' => $this->getSetting('outlookCalendar', 'enableMicrosoftTeams'), |
| 208 | ], |
| 209 | 'appleCalendar' => |
| 210 | $this->getSetting('appleCalendar', 'clientID') && $this->getSetting('appleCalendar', 'clientSecret'), |
| 211 | 'zoom' => [ |
| 212 | 'enabled' => ( |
| 213 | $this->getSetting('zoom', 'enabled') && |
| 214 | $this->getSetting('zoom', 'accountId') && |
| 215 | $this->getSetting('zoom', 'clientId') && |
| 216 | $this->getSetting('zoom', 'clientSecret') |
| 217 | ) |
| 218 | ], |
| 219 | 'facebookPixel' => $this->getCategorySettings('facebookPixel'), |
| 220 | 'googleAnalytics' => $this->getCategorySettings('googleAnalytics'), |
| 221 | 'googleTag' => $this->getCategorySettings('googleTag'), |
| 222 | 'lessonSpace' => [ |
| 223 | 'enabled' => $this->getSetting('lessonSpace', 'enabled') && $this->getSetting('lessonSpace', 'apiKey') |
| 224 | ], |
| 225 | 'notifications' => [ |
| 226 | 'senderName' => $this->getSetting('notifications', 'senderName'), |
| 227 | 'replyTo' => $this->getSetting('notifications', 'replyTo'), |
| 228 | 'senderEmail' => $this->getSetting('notifications', 'senderEmail'), |
| 229 | 'notifyCustomers' => $this->getSetting('notifications', 'notifyCustomers'), |
| 230 | 'sendAllCF' => $this->getSetting('notifications', 'sendAllCF'), |
| 231 | 'cancelSuccessUrl' => $this->getSetting('notifications', 'cancelSuccessUrl'), |
| 232 | 'cancelErrorUrl' => $this->getSetting('notifications', 'cancelErrorUrl'), |
| 233 | 'approveSuccessUrl' => $this->getSetting('notifications', 'approveSuccessUrl'), |
| 234 | 'approveErrorUrl' => $this->getSetting('notifications', 'approveErrorUrl'), |
| 235 | 'rejectSuccessUrl' => $this->getSetting('notifications', 'rejectSuccessUrl'), |
| 236 | 'rejectErrorUrl' => $this->getSetting('notifications', 'rejectErrorUrl'), |
| 237 | 'smsSignedIn' => $this->getSetting('notifications', 'smsSignedIn'), |
| 238 | 'bccEmail' => $this->getSetting('notifications', 'bccEmail'), |
| 239 | 'bccSms' => $this->getSetting('notifications', 'bccSms'), |
| 240 | 'smsBalanceEmail' => $this->getSetting('notifications', 'smsBalanceEmail'), |
| 241 | 'whatsAppPhoneID' => $this->getSetting('notifications', 'whatsAppPhoneID'), |
| 242 | 'whatsAppAccessToken' => $this->getSetting('notifications', 'whatsAppAccessToken'), |
| 243 | 'whatsAppBusinessID' => $this->getSetting('notifications', 'whatsAppBusinessID'), |
| 244 | 'whatsAppLanguage' => $this->getSetting('notifications', 'whatsAppLanguage'), |
| 245 | 'whatsAppEnabled' => $this->getSetting('notifications', 'whatsAppEnabled'), |
| 246 | ], |
| 247 | 'payments' => [ |
| 248 | 'currency' => $this->getSetting('payments', 'symbol'), |
| 249 | 'currencyCode' => $this->getSetting('payments', 'currency'), |
| 250 | 'priceSymbolPosition' => $this->getSetting('payments', 'priceSymbolPosition'), |
| 251 | 'priceNumberOfDecimals' => $this->getSetting('payments', 'priceNumberOfDecimals'), |
| 252 | 'priceSeparator' => $this->getSetting('payments', 'priceSeparator'), |
| 253 | 'hideCurrencySymbolFrontend' => $this->getSetting('payments', 'hideCurrencySymbolFrontend'), |
| 254 | 'defaultPaymentMethod' => $this->getSetting('payments', 'defaultPaymentMethod'), |
| 255 | 'onSite' => $this->getSetting('payments', 'onSite'), |
| 256 | 'couponsCaseInsensitive' => $this->getSetting('payments', 'couponsCaseInsensitive'), |
| 257 | 'coupons' => $this->getSetting('payments', 'coupons'), |
| 258 | 'taxes' => $this->getSetting('payments', 'taxes'), |
| 259 | 'cart' => $this->getSetting('payments', 'cart'), |
| 260 | 'paymentLinks' => [ |
| 261 | 'enabled' => $this->getSetting('payments', 'paymentLinks')['enabled'], |
| 262 | 'changeBookingStatus' => $this->getSetting('payments', 'paymentLinks')['changeBookingStatus'], |
| 263 | 'redirectUrl' => $this->getSetting('payments', 'paymentLinks')['redirectUrl'] |
| 264 | ], |
| 265 | 'payPal' => [ |
| 266 | 'enabled' => $this->getSetting('payments', 'payPal')['enabled'], |
| 267 | 'sandboxMode' => $this->getSetting('payments', 'payPal')['sandboxMode'], |
| 268 | 'testApiClientId' => $this->getSetting('payments', 'payPal')['testApiClientId'], |
| 269 | 'liveApiClientId' => $this->getSetting('payments', 'payPal')['liveApiClientId'], |
| 270 | ], |
| 271 | 'stripe' => [ |
| 272 | 'enabled' => $this->getSetting('payments', 'stripe')['enabled'], |
| 273 | 'testMode' => $this->getSetting('payments', 'stripe')['testMode'], |
| 274 | 'livePublishableKey' => $this->getSetting('payments', 'stripe')['livePublishableKey'], |
| 275 | 'testPublishableKey' => $this->getSetting('payments', 'stripe')['testPublishableKey'], |
| 276 | 'connect' => $this->getSetting('payments', 'stripe')['connect'], |
| 277 | 'address' => $this->getSetting('payments', 'stripe')['address'], |
| 278 | ], |
| 279 | 'wc' => [ |
| 280 | 'enabled' => $this->getSetting('payments', 'wc')['enabled'], |
| 281 | 'productId' => $this->getSetting('payments', 'wc')['productId'], |
| 282 | 'page' => $this->getSetting('payments', 'wc')['page'], |
| 283 | 'onSiteIfFree' => $this->getSetting('payments', 'wc')['onSiteIfFree'] |
| 284 | ], |
| 285 | 'mollie' => [ |
| 286 | 'enabled' => $this->getSetting('payments', 'mollie')['enabled'], |
| 287 | 'cancelBooking' => $this->getSetting('payments', 'mollie')['cancelBooking'], |
| 288 | ], |
| 289 | 'square' => [ |
| 290 | 'enabled' => $this->getSetting('payments', 'square')['enabled'], |
| 291 | 'testMode' => $this->getSetting('payments', 'square')['testMode'], |
| 292 | 'accessTokenSet' => !empty($this->getSetting('payments', 'square')['accessToken']) && !empty($this->getSetting('payments', 'square')['accessToken']['access_token']), |
| 293 | 'locationId' => $this->getSetting('payments', 'square')['locationId'] |
| 294 | ], |
| 295 | 'razorpay' => [ |
| 296 | 'enabled' => $this->getSetting('payments', 'razorpay')['enabled'], |
| 297 | ], |
| 298 | ], |
| 299 | 'role' => $userType, |
| 300 | 'weekSchedule' => $this->getCategorySettings('weekSchedule'), |
| 301 | 'wordpress' => [ |
| 302 | 'dateFormat' => $this->getSetting('wordpress', 'dateFormat'), |
| 303 | 'timeFormat' => $this->getSetting('wordpress', 'timeFormat'), |
| 304 | 'startOfWeek' => (int)$this->getSetting('wordpress', 'startOfWeek'), |
| 305 | 'timezone' => $this->getSetting('wordpress', 'timeZoneString'), |
| 306 | 'locale' => AMELIA_LOCALE |
| 307 | ], |
| 308 | 'labels' => [ |
| 309 | 'enabled' => $this->getSetting('labels', 'enabled') |
| 310 | ], |
| 311 | 'activation' => [ |
| 312 | 'showAmeliaSurvey' => $this->getSetting('activation', 'showAmeliaSurvey'), |
| 313 | 'showAmeliaPromoCustomizePopup' => $this->getSetting('activation', 'showAmeliaPromoCustomizePopup'), |
| 314 | 'showActivationSettings' => $this->getSetting('activation', 'showActivationSettings'), |
| 315 | 'stash' => $this->getSetting('activation', 'stash'), |
| 316 | 'disableUrlParams' => $this->getSetting('activation', 'disableUrlParams'), |
| 317 | 'isNewInstallation' => $this->getSetting('activation', 'isNewInstallation'), |
| 318 | 'hideUnavailableFeatures' => $this->getSetting('activation', 'hideUnavailableFeatures'), |
| 319 | 'premiumBannerVisibility' => $this->getSetting('activation', 'premiumBannerVisibility'), |
| 320 | 'dismissibleBannerVisibility' => $this->getSetting('activation', 'dismissibleBannerVisibility'), |
| 321 | ], |
| 322 | 'roles' => [ |
| 323 | 'allowAdminBookAtAnyTime' => $this->getSetting('roles', 'allowAdminBookAtAnyTime'), |
| 324 | 'adminServiceDurationAsSlot' => $this->getSetting('roles', 'adminServiceDurationAsSlot'), |
| 325 | 'allowConfigureSchedule' => $this->getSetting('roles', 'allowConfigureSchedule'), |
| 326 | 'allowConfigureDaysOff' => $this->getSetting('roles', 'allowConfigureDaysOff'), |
| 327 | 'allowConfigureSpecialDays' => $this->getSetting('roles', 'allowConfigureSpecialDays'), |
| 328 | 'allowConfigureServices' => $this->getSetting('roles', 'allowConfigureServices'), |
| 329 | 'allowWriteAppointments' => $this->getSetting('roles', 'allowWriteAppointments'), |
| 330 | 'allowWriteCustomers' => $this->getSetting('roles', 'allowWriteCustomers'), |
| 331 | 'automaticallyCreateCustomer' => $this->getSetting('roles', 'automaticallyCreateCustomer'), |
| 332 | 'inspectCustomerInfo' => $this->getSetting('roles', 'inspectCustomerInfo'), |
| 333 | 'allowCustomerReschedule' => $this->getSetting('roles', 'allowCustomerReschedule'), |
| 334 | 'allowCustomerCancelPackages' => $this->getSetting('roles', 'allowCustomerCancelPackages'), |
| 335 | 'allowCustomerDeleteProfile' => $this->getSetting('roles', 'allowCustomerDeleteProfile'), |
| 336 | 'allowWriteEvents' => $this->getSetting('roles', 'allowWriteEvents'), |
| 337 | 'customerCabinet' => [ |
| 338 | 'enabled' => $this->getSetting('roles', 'customerCabinet')['enabled'], |
| 339 | 'loginEnabled' => $this->getSetting('roles', 'customerCabinet')['loginEnabled'], |
| 340 | 'tokenValidTime' => $this->getSetting('roles', 'customerCabinet')['tokenValidTime'], |
| 341 | 'pageUrl' => $this->getSetting('roles', 'customerCabinet')['pageUrl'], |
| 342 | ], |
| 343 | 'providerCabinet' => [ |
| 344 | 'enabled' => $this->getSetting('roles', 'providerCabinet')['enabled'], |
| 345 | 'loginEnabled' => $this->getSetting('roles', 'providerCabinet')['loginEnabled'], |
| 346 | 'tokenValidTime' => $this->getSetting('roles', 'providerCabinet')['tokenValidTime'], |
| 347 | ], |
| 348 | 'providerBadges' => $this->getSetting('roles', 'providerBadges'), |
| 349 | 'enableNoShowTag' => $this->getSetting('roles', 'enableNoShowTag'), |
| 350 | 'limitPerCustomerService' => $this->getSetting('roles', 'limitPerCustomerService'), |
| 351 | 'limitPerCustomerPackage' => $this->getSetting('roles', 'limitPerCustomerPackage'), |
| 352 | 'limitPerCustomerEvent' => $this->getSetting('roles', 'limitPerCustomerEvent'), |
| 353 | 'limitPerEmployee' => $this->getSetting('roles', 'limitPerEmployee'), |
| 354 | ], |
| 355 | 'customization' => $this->getCategorySettings('customization'), |
| 356 | 'customizedData' => $this->getCategorySettings('customizedData'), |
| 357 | 'appointments' => $this->getCategorySettings('appointments'), |
| 358 | 'slotDateConstraints' => [ |
| 359 | 'minDate' => DateTimeService::getNowDateTimeObject() |
| 360 | ->modify("+{$this->getSetting('general', 'minimumTimeRequirementPriorToBooking')} seconds") |
| 361 | ->format('Y-m-d H:i:s'), |
| 362 | 'maxDate' => DateTimeService::getNowDateTimeObject() |
| 363 | ->modify("+{$this->getSetting('general', 'numberOfDaysAvailableForBooking')} day") |
| 364 | ->format('Y-m-d H:i:s') |
| 365 | ], |
| 366 | 'company' => [ |
| 367 | 'email' => $this->getSetting('company', 'email'), |
| 368 | 'phone' => $this->getSetting('company', 'phone'), |
| 369 | ] |
| 370 | ]; |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * @param $settingCategoryKey |
| 375 | * @param $settingKey |
| 376 | * @param $settingValue |
| 377 | * |
| 378 | * @return mixed|void |
| 379 | */ |
| 380 | public function setSetting($settingCategoryKey, $settingKey, $settingValue) |
| 381 | { |
| 382 | $this->settingsCache[$settingCategoryKey][$settingKey] = $settingValue; |
| 383 | $settingsCopy = $this->settingsCache; |
| 384 | |
| 385 | unset($settingsCopy['wordpress']); |
| 386 | update_option('amelia_settings', json_encode($settingsCopy)); |
| 387 | } |
| 388 | |
| 389 | /** |
| 390 | * @param $settingCategoryKey |
| 391 | * @param $settingValues |
| 392 | * |
| 393 | * @return mixed|void |
| 394 | */ |
| 395 | public function setCategorySettings($settingCategoryKey, $settingValues) |
| 396 | { |
| 397 | $this->settingsCache[$settingCategoryKey] = $settingValues; |
| 398 | $settingsCopy = $this->settingsCache; |
| 399 | |
| 400 | unset($settingsCopy['wordpress']); |
| 401 | update_option('amelia_settings', json_encode($settingsCopy)); |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * @param array $settings |
| 406 | * |
| 407 | * @return mixed|void |
| 408 | */ |
| 409 | public function setAllSettings($settings) |
| 410 | { |
| 411 | foreach ($settings as $settingCategoryKey => $settingValues) { |
| 412 | $this->settingsCache[$settingCategoryKey] = $settingValues; |
| 413 | } |
| 414 | $settingsCopy = $this->settingsCache; |
| 415 | |
| 416 | Licence\DataModifier::restoreSettings($settingsCopy, self::getSavedSettings()); |
| 417 | |
| 418 | if (get_option('amelia_show_wpdt_promo') === false) { |
| 419 | update_option('amelia_show_wpdt_promo', 'yes' ); |
| 420 | } |
| 421 | |
| 422 | unset($settingsCopy['wordpress']); |
| 423 | update_option('amelia_settings', json_encode($settingsCopy)); |
| 424 | } |
| 425 | } |
| 426 |