PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
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 10.10.2 All 205 releases
booking / includes / page-setup-wizard / step-review-setup / class-wpbc-setup-wizard-review-setup-module.php

class-wpbc-setup-wizard-review-setup-module.php in Booking Calendar 11.9, at includes/page-setup-wizard/step-review-setup/class-wpbc-setup-wizard-review-setup-module.php

157 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Setup Wizard module adapter for the reviewed setup plan.
4 *
5 * @package Booking Calendar
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 /**
13 * Expose the read-only review plan through the common step-module contract.
14 */
15 final class WPBC_Setup_Wizard_Review_Setup_Module implements WPBC_Setup_Wizard_Step_Module {
16
17 /** @var WPBC_Setup_Wizard_Review_Setup */
18 private $review_setup;
19
20 /**
21 * Build the adapter around the review presentation service.
22 *
23 * @param WPBC_Setup_Wizard_Review_Setup|null $review_setup Optional service for tests.
24 */
25 public function __construct( $review_setup = null ) {
26 $this->review_setup = $review_setup instanceof WPBC_Setup_Wizard_Review_Setup ? $review_setup : new WPBC_Setup_Wizard_Review_Setup();
27 }
28
29 /**
30 * Return the stable step identifier.
31 *
32 * @return string Stable step ID.
33 */
34 public function get_step_id() {
35 return 'review_setup';
36 }
37
38 /**
39 * Return rail, template, and footer metadata.
40 *
41 * @return array<string,string> Step definition.
42 */
43 public function get_step_definition() {
44 return array(
45 'id' => $this->get_step_id(),
46 'label' => __( 'Your setup plan', 'booking' ),
47 'template' => 'step-review-setup',
48 'footer_note' => __( 'Finish setup revalidates the active route and completes the wizard. Settings and publishing changes saved on earlier steps remain active.', 'booking' ),
49 );
50 }
51
52 /**
53 * Return the allow-listed template path.
54 *
55 * @return string Absolute template path.
56 */
57 public function get_template_path() {
58 return __DIR__ . '/template.php';
59 }
60
61 /**
62 * Return the empty Review Setup field allow-list.
63 *
64 * @return string[] Field allow-list.
65 */
66 public function get_field_names() {
67 return array();
68 }
69
70 /**
71 * Return the empty required-field list.
72 *
73 * @return string[] Required field IDs.
74 */
75 public function get_required_fields() {
76 return array();
77 }
78
79 /**
80 * Return the field-free initial state.
81 *
82 * @return array<string,mixed> Initial values.
83 */
84 public function get_initial_values() {
85 return array();
86 }
87
88 /**
89 * Return every earlier step that can contribute a review row.
90 *
91 * @return string[] Dependency step identifiers.
92 */
93 public function get_context_dependencies() {
94 return array(
95 'business_details',
96 'date_time_formats',
97 'booking_experience',
98 'customer_journey',
99 'date_selection',
100 'services',
101 'booking_resources',
102 'start_end_times',
103 'start_duration_times',
104 'fixed_time_slots',
105 'working_hours',
106 'days_off',
107 'booking_form_template',
108 'appearance',
109 'publish_integration',
110 );
111 }
112
113 /**
114 * Build the data-only review context.
115 *
116 * @param array<string,mixed> $field_values Review-step values; currently empty.
117 * @param array<string,mixed> $consumer_context Validated earlier-step values.
118 *
119 * @return array<string,mixed> Review presentation data.
120 */
121 public function get_context( array $field_values, array $consumer_context = array() ) {
122 return $this->review_setup->get_context( $field_values, $consumer_context );
123 }
124
125 /**
126 * Reject every submitted field because Review Setup has no editable fields.
127 *
128 * @param string $field_id Stable field ID.
129 * @param mixed $raw_value Untrusted submitted value.
130 * @param bool $is_required Whether acknowledgment is required.
131 *
132 * @return WP_Error Unsupported-field error.
133 */
134 public function validate_field( $field_id, $raw_value, $is_required ) {
135 unset( $field_id, $raw_value, $is_required );
136
137 return new WP_Error( 'wpbc_setup_wizard_review_field_unknown', __( 'The setup review received an unsupported field.', 'booking' ) );
138 }
139
140 /**
141 * Enqueue the compiled review-page stylesheet.
142 *
143 * @param string $module_url Setup Wizard module URL.
144 * @param string|false $asset_version Plugin asset version.
145 * @param string $shared_style_handle Shared shell style handle.
146 * @param string $shared_script_handle Shared shell script handle.
147 *
148 * @return void
149 */
150 public function enqueue_assets( $module_url, $asset_version, $shared_style_handle, $shared_script_handle ) {
151 unset( $shared_script_handle );
152 $module_url = trailingslashit( $module_url );
153
154 wp_enqueue_style( 'wpbc-setup-wizard-review-setup', $module_url . 'step-review-setup/_out/step-review-setup.css', array( $shared_style_handle ), $asset_version );
155 }
156 }
157