← All changes
|
includes/booking-resource-selector/booking-resource-selector__render.php
+42
-19
11.5
→
11.9
View file →
| @@ -165,29 +165,51 @@ | ||
| 165 | 165 | $selected_resource_id = wpbc_booking_resource_selector_get_default_resource_id( $config ); |
| 166 | 166 | $html = wpbc_booking_resource_selector_render_progress( 1, $config ); |
| 167 | 167 | $html .= wpbc_booking_resource_selector_render_screen_heading( $config, __( 'Choose a Booking Resource', 'booking' ), __( 'Select what you would like to book.', 'booking' ) ); |
| 168 | 168 | $html .= '<form class="wpbc_booking_resource_selector__selection_form" method="get" action="' . esc_url( wpbc_booking_resource_selector_get_fallback_url( $config ) ) . '">'; |
| 169 | - $html .= '<div class="wpbc_booking_resource_selector__choices" role="radiogroup" aria-label="' . esc_attr__( 'Booking Resources', 'booking' ) . '">'; | |
| 170 | - foreach ( $catalog as $resource ) { | |
| 171 | - $resource_id = absint( $resource['resource_id'] ); | |
| 172 | - $input_id = 'wpbc_resource_selector_' . $resource_id . '_' . wp_rand( 1000, 9999 ); | |
| 173 | - $is_selected = $resource_id === $selected_resource_id; | |
| 174 | - $html .= '<label class="wpbc_booking_resource_selector__choice' . ( $is_selected ? ' is-selected' : '' ) . '" for="' . esc_attr( $input_id ) . '">'; | |
| 175 | - $html .= '<input id="' . esc_attr( $input_id ) . '" type="radio" name="wpbc_resource_selector_resource" value="' . $resource_id . '"' . checked( $is_selected, true, false ) . ' required>'; | |
| 176 | - $html .= '<span class="wpbc_booking_resource_selector__resource_icon" aria-hidden="true">'; | |
| 177 | - if ( ! empty( $resource['image_url'] ) ) { | |
| 178 | - $html .= '<img src="' . esc_url( $resource['image_url'] ) . '" alt="" loading="lazy" decoding="async">'; | |
| 179 | - } else { | |
| 180 | - $html .= esc_html( wpbc_booking_resource_selector_get_resource_initials( $resource['title'] ) ); | |
| 169 | + if ( function_exists( 'wpbc_booking_resource_catalog_presenter' ) ) { | |
| 170 | + $html .= wpbc_booking_resource_catalog_presenter()->render_selectable_catalog( | |
| 171 | + $catalog, | |
| 172 | + array( | |
| 173 | + 'layout' => $config['catalog_layout'], | |
| 174 | + 'show_filters' => $config['show_resource_filters'], | |
| 175 | + 'show_image' => $config['show_resource_image'], | |
| 176 | + 'show_title' => $config['show_resource_title'], | |
| 177 | + 'show_description' => $config['show_resource_description'], | |
| 178 | + 'item_width' => $config['catalog_item_width'], | |
| 179 | + 'item_max_width' => $config['catalog_item_max_width'], | |
| 180 | + 'grid_items_per_row' => $config['catalog_grid_items_per_row'], | |
| 181 | + 'list_items_per_row' => $config['catalog_list_items_per_row'], | |
| 182 | + 'show_hierarchy' => $config['show_resource_hierarchy'], | |
| 183 | + 'show_availability' => $config['show_availability'], | |
| 184 | + 'show_price' => $config['show_starting_price'], | |
| 185 | + 'selected_resource_id' => $selected_resource_id, | |
| 186 | + ) | |
| 187 | + ); | |
| 188 | + } else { | |
| 189 | + $html .= '<div class="wpbc_booking_resource_selector__choices" role="radiogroup" aria-label="' . esc_attr__( 'Booking Resources', 'booking' ) . '">'; | |
| 190 | + foreach ( $catalog as $resource ) { | |
| 191 | + $resource_id = absint( $resource['resource_id'] ); | |
| 192 | + $input_id = 'wpbc_resource_selector_' . $resource_id . '_' . wp_rand( 1000, 9999 ); | |
| 193 | + $is_selected = $resource_id === $selected_resource_id; | |
| 194 | + $html .= '<label class="wpbc_booking_resource_selector__choice' . ( $is_selected ? ' is-selected' : '' ) . '" for="' . esc_attr( $input_id ) . '">'; | |
| 195 | + $html .= '<input id="' . esc_attr( $input_id ) . '" type="radio" name="wpbc_resource_selector_resource" value="' . $resource_id . '"' . checked( $is_selected, true, false ) . ' required>'; | |
| 196 | + $html .= '<span class="wpbc_booking_resource_selector__resource_icon" aria-hidden="true">'; | |
| 197 | + if ( ! empty( $resource['image_url'] ) ) { | |
| 198 | + $html .= '<img src="' . esc_url( $resource['image_url'] ) . '" alt="" loading="lazy" decoding="async">'; | |
| 199 | + } else { | |
| 200 | + $html .= esc_html( wpbc_booking_resource_selector_get_resource_initials( $resource['title'] ) ); | |
| 201 | + } | |
| 202 | + $html .= '</span>'; | |
| 203 | + $html .= '<span class="wpbc_booking_resource_selector__choice_body"><strong>' . esc_html( $resource['title'] ) . '</strong>'; | |
| 204 | + if ( ! empty( $resource['description'] ) ) { | |
| 205 | + $html .= '<span class="wpbc_booking_resource_selector__choice_description">' . esc_html( $resource['description'] ) . '</span>'; | |
| 206 | + } | |
| 207 | + $html .= '</span><span class="wpbc_booking_resource_selector__choice_mark" aria-hidden="true"></span></label>'; | |
| 181 | 208 | } |
| 182 | - $html .= '</span>'; | |
| 183 | - $html .= '<span class="wpbc_booking_resource_selector__choice_body"><strong>' . esc_html( $resource['title'] ) . '</strong>'; | |
| 184 | - if ( ! empty( $resource['description'] ) ) { | |
| 185 | - $html .= '<span class="wpbc_booking_resource_selector__choice_description">' . esc_html( $resource['description'] ) . '</span>'; | |
| 186 | - } | |
| 187 | - $html .= '</span><span class="wpbc_booking_resource_selector__choice_mark" aria-hidden="true"></span></label>'; | |
| 209 | + $html .= '</div>'; | |
| 188 | 210 | } |
| 189 | - $html .= '</div><input type="hidden" name="wpbc_resource_selector_config" value="' . esc_attr( $config_token ) . '">'; | |
| 211 | + $html .= '<input type="hidden" name="wpbc_resource_selector_config" value="' . esc_attr( $config_token ) . '">'; | |
| 190 | 212 | $html .= '<div class="wpbc_booking_resource_selector__actions"><button type="submit" class="wpbc_button wpbc_button_primary wpbc_booking_resource_selector__continue">' . esc_html__( 'Continue', 'booking' ) . '</button></div></form>'; |
| 191 | 213 | |
| 192 | 214 | return $html; |
| 193 | 215 | } |
| @@ -261,8 +283,9 @@ | ||
| 261 | 283 | 'selected_dates_without_calendar' => $config['selected_dates'], |
| 262 | 284 | 'shortcode_param__options' => $config['options'], |
| 263 | 285 | 'calendar_dates_start' => $config['calendar_dates_start'], |
| 264 | 286 | 'calendar_dates_end' => $config['calendar_dates_end'], |
| 287 | + 'booking_workflow' => 'resource_selector', | |
| 265 | 288 | 'calendar_request_overrides' => array( |
| 266 | 289 | 'allow_past' => $allow_past ? 1 : 0, |
| 267 | 290 | ), |
| 268 | 291 | ); |