PluginProbe
404 Solution / trunk
404 Solution vtrunk
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / settings / SetupWizardOptionStore.php

SetupWizardOptionStore.php in 404 Solution trunk, at includes/settings/SetupWizardOptionStore.php

63 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // allow-no-test-found: covered by tests/SetupWizardTest.php through setup wizard form submission entry points.
4
5 if (!defined('ABSPATH')) {
6 exit;
7 }
8
9 /**
10 * Reads and persists setup wizard state.
11 */
12 class ABJ_404_Solution_SetupWizardOptionStore {
13
14 public const OPTION_NAME = 'abj404_setup_completed';
15
16 /**
17 * Return true when the setup wizard has already been completed.
18 *
19 * @return bool
20 */
21 public static function isComplete(): bool {
22 $completed = get_option(self::OPTION_NAME, '');
23 return !empty($completed);
24 }
25
26 /**
27 * Persist today's setup completion marker.
28 *
29 * @return void
30 */
31 public static function markCompleteToday(): void {
32 update_option(self::OPTION_NAME, gmdate('Y-m-d', abj_clock()->now()));
33 }
34
35 /**
36 * Return the currently persisted plugin options.
37 *
38 * @return array<string,mixed>
39 */
40 public static function loadPluginOptions(): array {
41 $optionsRepository = abj_service('options_repository');
42 $options = $optionsRepository->getOptions();
43 return is_array($options) ? $options : array();
44 }
45
46 /**
47 * Return the site administrator email used by setup decisions.
48 */
49 public static function adminEmail(): string {
50 $adminEmail = get_option('admin_email');
51 return is_string($adminEmail) ? $adminEmail : '';
52 }
53
54 /**
55 * Persist plugin options already derived by the setup policy.
56 *
57 * @param array<string,mixed> $options
58 */
59 public static function savePluginOptions(array $options): void {
60 abj_service('options_repository')->updateOptions($options);
61 }
62 }
63