PluginProbe
The Innovative Form Builder – IvyForms / 1.0
The Innovative Form Builder – IvyForms v1.0
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / InstallActions / ActivationSettingsHook.php

ActivationSettingsHook.php in The Innovative Form Builder – IvyForms 1.0, at backend/src/Services/InstallActions/ActivationSettingsHook.php

98 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Settings hook for activation
5 */
6
7 namespace IvyForms\Services\InstallActions;
8
9 use Exception;
10 use IvyForms\Services\Settings\SettingsService;
11
12 /**
13 * Class ActivationSettingsHook
14 *
15 * @package IvyForms\Services\InstallActions
16 */
17 class ActivationSettingsHook
18 {
19 /**
20 * Initialize the plugin
21 *
22 * @throws Exception
23 */
24 public static function init(): void
25 {
26 self::initGeneralSettings();
27 self::initIntegrationsSettings();
28 }
29
30 /**
31 * @param string $category
32 * @param mixed[] $settings
33 */
34 public static function initSettings(string $category, array $settings): void
35 {
36 $settingsStorage = new SettingsService();
37
38 if (!$settingsStorage->getCategorySettings($category)) {
39 $settingsStorage->setCategorySettings(
40 $category,
41 []
42 );
43 }
44
45 foreach ($settings as $key => $value) {
46 if (null === $settingsStorage->getSetting($category, $key)) {
47 $settingsStorage->setSetting(
48 $category,
49 $key,
50 $value
51 );
52 }
53 }
54 }
55
56 /**
57 * Init General Settings
58 */
59 private static function initGeneralSettings(): void
60 {
61
62 $settings = [
63 'version' => IVYFORMS_VERSION,
64 'changelog_lite_version' => '',
65 'changelog_pro_version' => '',
66 'fullscreen' => false,
67 ];
68
69 self::initSettings('general', $settings);
70
71 // On activation/reactivation, sync stored changelog versions to current versions
72 // so changelog is only shown on real version updates.
73 $settingsStorage = new SettingsService();
74 $settingsStorage->setSetting('general', 'changelog_lite_version', IVYFORMS_VERSION);
75
76 if (defined('IVYFORMS_PRO_VERSION')) {
77 $settingsStorage->setSetting('general', 'changelog_pro_version', IVYFORMS_PRO_VERSION);
78 }
79 }
80
81 /**
82 * Init Integrations Settings
83 */
84 private static function initIntegrationsSettings(): void
85 {
86 $settings = [
87 'wpdatatables' => [
88 'enabled' => false,
89 ],
90 'mailchimp' => [
91 'enabled' => false,
92 ],
93 ];
94
95 self::initSettings('integrations', $settings);
96 }
97 }
98