PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9.1 11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 All 206 releases
booking / includes / page-setup-wizard / class-wpbc-setup-wizard-metadata-save-handler.php

class-wpbc-setup-wizard-metadata-save-handler.php in Booking Calendar 11.9, at includes/page-setup-wizard/class-wpbc-setup-wizard-metadata-save-handler.php

100 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Setup Wizard metadata-only progressive save handler.
4 *
5 * @package Booking Calendar
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * Record one validated metadata step without changing Booking Calendar settings.
14 *
15 * Welcome, Business details, and Customer Journey are wizard-owned metadata.
16 * They still use an explicit handler so their progressive-save boundary,
17 * authorization, result summary, and future extension point are unambiguous.
18 */
19 final class WPBC_Setup_Wizard_Metadata_Save_Handler implements WPBC_Setup_Wizard_Step_Save_Handler {
20
21 /** @var string */
22 private $step_id;
23
24 /** @var string */
25 private $summary;
26
27 /**
28 * Configure one metadata-only step.
29 *
30 * @param string $step_id Stable step identifier.
31 * @param string $summary Translated result summary.
32 */
33 public function __construct( $step_id, $summary ) {
34 $this->step_id = sanitize_key( (string) $step_id );
35 $this->summary = sanitize_text_field( (string) $summary );
36 }
37
38 /**
39 * Return the owned step identifier.
40 *
41 * @return string Stable step identifier.
42 */
43 public function get_step_id() {
44 return $this->step_id;
45 }
46
47 /**
48 * Return the ordinary progressive-save action label.
49 *
50 * @param array<string,mixed> $checkpoint Current checkpoint.
51 * @param array<string,mixed> $step_context Authorized presentation context.
52 *
53 * @return string Translated action label.
54 */
55 public function get_primary_action_label( array $checkpoint, array $step_context = array() ) {
56 unset( $checkpoint, $step_context );
57
58 return __( 'Save & continue', 'booking' );
59 }
60
61 /**
62 * Recheck access and return a metadata-only result.
63 *
64 * Field validation is owned by the shared draft validator before this method
65 * runs. No canonical plugin setting belongs to these steps.
66 *
67 * @param array<string,mixed> $validated_fields Validated current-step fields.
68 * @param array<string,mixed> $checkpoint Current checkpoint.
69 * @param array<string,mixed> $operation_context Stable operation metadata.
70 *
71 * @return array<string,mixed>|WP_Error Normalized result proposal or access error.
72 */
73 public function save( array $validated_fields, array $checkpoint, array $operation_context ) {
74 unset( $validated_fields, $checkpoint, $operation_context );
75
76 if ( ! WPBC_Setup_Wizard_Access::current_user_can_access() ) {
77 return new WP_Error( 'wpbc_setup_wizard_metadata_forbidden', __( 'You are not allowed to save this Setup Wizard step.', 'booking' ) );
78 }
79
80 return array(
81 'status' => 'saved',
82 'summary' => $this->summary,
83 'canonical_fingerprint' => '',
84 'created_ids' => array(),
85 'updated_ids' => array(),
86 'warnings' => array(),
87 'writes_canonical_settings' => false,
88 );
89 }
90
91 /**
92 * Metadata steps never complete the route.
93 *
94 * @return bool False.
95 */
96 public function is_terminal() {
97 return false;
98 }
99 }
100