| 1 |
<?php |
| 2 |
/** |
| 3 |
* Non-domain Setup Wizard save handler used during progressive-save rollout. |
| 4 |
* |
| 5 |
* @package Booking Calendar |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Record validated progress without mutating Booking Calendar domain settings. |
| 14 |
* |
| 15 |
* Phase 2 retains this handler for later complex steps. Subsequent phases |
| 16 |
* replace exact registrations with domain-owned handlers one step at a time. |
| 17 |
* Its explicit result flag lets tests prove that shared navigation cannot |
| 18 |
* accidentally claim or perform a canonical write before that replacement. |
| 19 |
*/ |
| 20 |
final class WPBC_Setup_Wizard_Checkpoint_Only_Save_Handler implements WPBC_Setup_Wizard_Step_Save_Handler { |
| 21 |
|
| 22 |
/** @var string */ |
| 23 |
private $step_id; |
| 24 |
|
| 25 |
/** @var string */ |
| 26 |
private $primary_action_label; |
| 27 |
|
| 28 |
/** @var bool */ |
| 29 |
private $is_terminal; |
| 30 |
|
| 31 |
/** |
| 32 |
* Configure one checkpoint-only step boundary. |
| 33 |
* |
| 34 |
* @param string $step_id Stable step identifier. |
| 35 |
* @param string $primary_action_label Translated primary action label. |
| 36 |
* @param bool $is_terminal Whether this is the final route step. |
| 37 |
*/ |
| 38 |
public function __construct( $step_id, $primary_action_label, $is_terminal = false ) { |
| 39 |
$this->step_id = sanitize_key( (string) $step_id ); |
| 40 |
$this->primary_action_label = sanitize_text_field( (string) $primary_action_label ); |
| 41 |
$this->is_terminal = (bool) $is_terminal; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Return the configured step identifier. |
| 46 |
* |
| 47 |
* @return string Stable step ID. |
| 48 |
*/ |
| 49 |
public function get_step_id() { |
| 50 |
return $this->step_id; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Return the configured server-owned action label. |
| 55 |
* |
| 56 |
* @param array<string,mixed> $checkpoint Unused current checkpoint. |
| 57 |
* @param array<string,mixed> $step_context Unused presentation context. |
| 58 |
* |
| 59 |
* @return string Translated action label. |
| 60 |
*/ |
| 61 |
public function get_primary_action_label( array $checkpoint, array $step_context = array() ) { |
| 62 |
unset( $checkpoint, $step_context ); |
| 63 |
|
| 64 |
return $this->primary_action_label; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Return an explicit non-domain result for checkpoint persistence. |
| 69 |
* |
| 70 |
* @param array<string,mixed> $validated_fields Validated current-step fields. |
| 71 |
* @param array<string,mixed> $checkpoint Current checkpoint. |
| 72 |
* @param array<string,mixed> $operation_context Stable operation metadata. |
| 73 |
* |
| 74 |
* @return array<string,mixed> Normalized checkpoint-only result proposal. |
| 75 |
*/ |
| 76 |
public function save( array $validated_fields, array $checkpoint, array $operation_context ) { |
| 77 |
unset( $validated_fields, $checkpoint, $operation_context ); |
| 78 |
|
| 79 |
return array( |
| 80 |
'status' => 'saved', |
| 81 |
'summary' => __( 'Setup Wizard progress saved.', 'booking' ), |
| 82 |
'canonical_fingerprint' => '', |
| 83 |
'created_ids' => array(), |
| 84 |
'updated_ids' => array(), |
| 85 |
'warnings' => array(), |
| 86 |
'writes_canonical_settings' => false, |
| 87 |
); |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Return whether this handler completes the route. |
| 92 |
* |
| 93 |
* @return bool True for the final checkpoint-only handler. |
| 94 |
*/ |
| 95 |
public function is_terminal() { |
| 96 |
return $this->is_terminal; |
| 97 |
} |
| 98 |
} |
| 99 |
|