PluginProbe
404 Solution / 4.3.0
404 Solution v4.3.0
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 4.3.0, at includes/settings/SetupWizardOptionStore.php

56 lines 1.5 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 * Persists setup wizard completion and setup-derived option changes.
11 */
12 class ABJ_404_Solution_SetupWizardOptionStore {
13
14 /**
15 * Return true when the setup wizard has already been completed.
16 *
17 * @return bool
18 */
19 public static function isComplete(): bool {
20 $completed = get_option(ABJ_404_Solution_SetupWizard::OPTION_NAME, '');
21 return !empty($completed);
22 }
23
24 /**
25 * Persist today's setup completion marker.
26 *
27 * @return void
28 */
29 public static function markCompleteToday(): void {
30 update_option(ABJ_404_Solution_SetupWizard::OPTION_NAME, gmdate('Y-m-d', abj_clock()->now()));
31 }
32
33 /**
34 * Persist plugin options derived from validated setup answers.
35 *
36 * @param array{q1:string,q2:string,q3:string} $answers Validated setup answers.
37 * @return void
38 */
39 public static function saveAnswers(array $answers): void {
40 $optionsRepository = abj_service('options_repository');
41 $options = $optionsRepository->getOptions();
42 if (!is_array($options)) {
43 $options = array();
44 }
45
46 $adminEmail = get_option('admin_email');
47 $options = ABJ_404_Solution_SetupWizardAnswerPolicy::applyToOptions(
48 $options,
49 $answers,
50 is_string($adminEmail) ? $adminEmail : ''
51 );
52
53 $optionsRepository->updateOptions($options);
54 }
55 }
56