PluginProbe
Booking Calendar / 11.2
Booking Calendar v11.2
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 10.11 10.11.2 All 203 releases
booking / includes / _toolbar_ui / ui__form_steps_timeline.php

ui__form_steps_timeline.php in Booking Calendar 11.2, at includes/_toolbar_ui/ui__form_steps_timeline.php

157 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Templates functions for showing Steps Timeline in Booking form and in Wizard.
4 *
5 * @version 1.0
6 * @package Booking Calendar
7 * @category Templates Fucntions
8 * @author wpdevelop
9 *
10 * @web-site https://wpbookingcalendar.com/
11 * @email info@wpbookingcalendar.com
12 *
13 * @modified 2025-01-28
14 */
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit, if accessed directly.
18 }
19
20 // FixIn: 10.9.6.6.
21
22 // ---------------------------------------------------------------------------------------------------------------------
23 // Steps Timeline in Booking form
24 // ---------------------------------------------------------------------------------------------------------------------
25
26 /**
27 * Get html for the 'Steps Timeline'
28 *
29 * @param int $steps_count - total number of steps.
30 * @param int $actual_step_number - active step.
31 *
32 * @return string
33 */
34 function wpbc_ui__steps_timeline__get_html( $steps_count, $actual_step_number = 1 ) {
35
36 ob_start();
37
38 ?>
39 <div class="wpbc_steps_for_timeline_container">
40 <div class="wpbc_steps_for_timeline">
41 <?php
42
43 $css_class_for_step = '';
44 $css_class_for_line = '';
45 $is_line_exist = false;
46
47 for ( $i = 1; $i <= $steps_count; $i++ ) {
48
49 $is_line_exist = ( $i > 1 ) ? true : false;
50
51 if ( $actual_step_number > $i ) {
52 $css_class_for_step = ' wpbc_steps_for_timeline_step_completed';
53 $css_class_for_line = 'wpbc_steps_for_timeline_line_active';
54 } elseif ( $actual_step_number === $i ) {
55 $css_class_for_step = ' wpbc_steps_for_timeline_step_active';
56 $css_class_for_line = 'wpbc_steps_for_timeline_line_active';
57 } else {
58 $css_class_for_step = '';
59 $css_class_for_line = '';
60 }
61
62 if ( $is_line_exist ) {
63 echo "<div class='wpbc_steps_for_timeline_step_line " . esc_attr( $css_class_for_line ) . "' ></div >";
64 }
65 echo "<div class='wpbc_steps_for_timeline_step " . esc_attr( $css_class_for_step ) . "'>";
66 echo wpbc_ui__steps_timeline__get_icons(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
67 echo '</div>';
68 }
69 ?>
70 </div>
71 </div>
72 <?php
73
74 $html = ob_get_clean();
75
76 return $html;
77 }
78
79
80 /**
81 * Get icons for the 'Steps Timeline'
82 *
83 * @return false|string
84 */
85 function wpbc_ui__steps_timeline__get_icons() {
86
87 ob_start();
88 ?>
89 <svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" role="img" class="icon icon-success" data-icon="check" data-prefix="fas" focusable="false" aria-hidden="true" width="10" height="10">
90 <path xmlns="http://www.w3.org/2000/svg" fill="currentColor" d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"></path>
91 </svg>
92 <svg viewBox="0 0 352 512" xmlns="http://www.w3.org/2000/svg" role="img" class="icon icon-failed" data-icon="times" data-prefix="fas" focusable="false" aria-hidden="true" width="8" height="11">
93 <path xmlns="http://www.w3.org/2000/svg" fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"></path>
94 </svg>
95 <?php
96
97 return ob_get_clean();
98 }
99
100
101 /**
102 * Update [steps_timeline] shortcode
103 *
104 * @param string $form_content - Form Content.
105 * @param int $resource_id - Resource ID.
106 * @param string $custom_booking_form_name - Custom booking form name ?.
107 *
108 * @return string
109 */
110 function wpbc_update_bookingform_content__steps_timeline( $form_content, $resource_id, $custom_booking_form_name = '' ) {
111
112 // $hint_html = wpbc_ui__steps_timeline__get_html( 3, 2 );
113 // $form_content = str_replace( '[steps_timeline]', $hint_html, $form_content );
114
115 /**
116 * Example: array(
117 * content => "<span class="wpbc_top_news_dismiss">[wpbc_dismiss6764]</span>"
118 * shortcodes => array(
119 * 'wpbc_dismiss6764' => array(
120 * shortcode => "[wpbc_dismiss6764]",
121 * params => array( id => "wpbc_top_news__offer_2023_04_21" )
122 * shortcode_original => "[wpbc_dismiss id="wpbc_top_news__offer_2023_04_21"]"
123 * )
124 * )
125 * )
126 */
127
128 $form_content = str_replace( 'steps_timline', 'steps_timeline', $form_content );
129 $shortcodes_arr = wpbc_get_shortcodes_in_text__as_unique_replace( $form_content, array( 'steps_timeline' ) );
130 $string = $shortcodes_arr['content'];
131
132
133 foreach ( $shortcodes_arr['shortcodes'] as $shortcode_text_to_replace => $shortcode_params_arr ) {
134 $steps_count = 1;
135 $step_number = 1;
136
137 if ( isset( $shortcode_params_arr['params']['steps_count'] ) ) {
138 $steps_count = intval( $shortcode_params_arr['params']['steps_count'] );
139 }
140 if ( isset( $shortcode_params_arr['params']['active_step'] ) ) {
141 $step_number = intval( $shortcode_params_arr['params']['active_step'] );
142 }
143 $new_html = '<span class="wpbc_steps_for_timeline__'.esc_attr($shortcode_text_to_replace).'">';
144 $new_html .= wpbc_ui__steps_timeline__get_html( $steps_count, $step_number );
145 $new_html .= '</span>';
146 if ( isset( $shortcode_params_arr['params']['color'] ) ) {
147 $color = esc_attr( $shortcode_params_arr['params']['color'] );
148 $new_html .= '<style type="text/css"> .booking_form_div .wpbc_steps_for_timeline__'.esc_attr($shortcode_text_to_replace).' .wpbc_steps_for_timeline_container { --wpbc_steps_for_timeline_active_color: ' . $color . '; } </style>';
149 }
150 $string = str_replace( '[' . $shortcode_text_to_replace . ']', $new_html, $string );
151 }
152
153 return $string;
154 }
155
156 add_filter( 'wpbc_booking_form_content__after_load', 'wpbc_update_bookingform_content__steps_timeline', 10, 3 );
157