PluginProbe
The Innovative Form Builder – IvyForms / 0.7
The Innovative Form Builder – IvyForms v0.7
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 0.7, at backend/src/Services/InstallActions/ActivationSettingsHook.php

93 lines 2.0 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 // phpcs:disable PSR1.Files.SideEffects
10 if (!defined('ABSPATH')) {
11 exit; // Exit if accessed directly
12 }
13
14 use Exception;
15 use IvyForms\Services\Settings\SettingsService;
16
17 /**
18 * Class ActivationSettingsHook
19 *
20 * @package IvyForms\Services\InstallActions
21 */
22 class ActivationSettingsHook
23 {
24 /**
25 * Initialize the plugin
26 *
27 * @throws Exception
28 */
29 public static function init(): void
30 {
31 self::initGeneralSettings();
32 self::initIntegrationsSettings();
33 }
34
35 /**
36 * @param string $category
37 * @param mixed[] $settings
38 */
39 public static function initSettings(string $category, array $settings): void
40 {
41 $settingsStorage = new SettingsService();
42
43 if (!$settingsStorage->getCategorySettings($category)) {
44 $settingsStorage->setCategorySettings(
45 $category,
46 []
47 );
48 }
49
50 foreach ($settings as $key => $value) {
51 if (null === $settingsStorage->getSetting($category, $key)) {
52 $settingsStorage->setSetting(
53 $category,
54 $key,
55 $value
56 );
57 }
58 }
59 }
60
61 /**
62 * Init General Settings
63 */
64 private static function initGeneralSettings(): void
65 {
66
67 $settings = [
68 'version' => IVYFORMS_VERSION,
69 'changelog_version' => '',
70 'fullscreen' => false,
71 ];
72
73 self::initSettings('general', $settings);
74 }
75
76 /**
77 * Init Integrations Settings
78 */
79 private static function initIntegrationsSettings(): void
80 {
81 $settings = [
82 'wpdatatables' => [
83 'enabled' => false,
84 ],
85 'mailchimp' => [
86 'enabled' => false,
87 ],
88 ];
89
90 self::initSettings('integrations', $settings);
91 }
92 }
93