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
← All changes | core/lib/wpbc-calendar-legend.php +79 -25 10.10.1 → 11.9 View file →
@@ -1,6 +1,9 @@
1 1 <?php
2 2
3 +if ( ! defined( 'ABSPATH' ) ) {
4 + exit; // Exit if accessed directly.
5 +}
3 6
4 7 // FixIn: 9.4.3.6.
5 8
6 9
@@ -8,9 +11,9 @@
8 11 * Get html content of " Calendar Legend Items " , based on General Settings configuration.
9 12 *
10 13 * @return string HTML content of legend items
11 14 */
12 -function wpbc_get_calendar_legend() {
15 +function wpbc_get_calendar_legend( $resource_id = 0 ) {
13 16
14 17 $calendar_legend_html = '';
15 18
16 19 if ( get_bk_option( 'booking_is_show_legend' ) == 'On' ) {
@@ -31,8 +34,9 @@
31 34 $calendar_legend_html = wpbc_get_calendar_legend__content_html( array(
32 35 'is_vertical' => ( 'On' != get_bk_option( 'booking_legend_is_vertical' ) ) ? false : true
33 36 , 'text_for_day_cell' => ( 'On' != get_bk_option( 'booking_legend_is_show_numbers' ) ) ? '&nbsp;' : gmdate( 'd' )
34 37 , 'items' => $items_sort
38 + , 'resource_id' => absint( $resource_id )
35 39 ) );
36 40 }
37 41
38 42 return $calendar_legend_html;
@@ -50,8 +54,9 @@
50 54 , 'pending'
51 55 , 'partially'
52 56 )
53 57 , 'unavailable_day_cell_tag' => 'span'
58 + , 'resource_id' => 0
54 59 , 'titles' => array()
55 60 );
56 61 $params = wp_parse_args( $params, $defaults );
57 62
@@ -67,9 +72,9 @@
67 72 $legend_arr[ $key ] .= '<td class="datepick-days-cell date_available wpbc_calendar_legend_day_cell_height">';
68 73 $legend_arr[ $key ] .= '<div class="wpbc-cell-box">';
69 74 $legend_arr[ $key ] .= ' <div class="date-cell-content">';
70 75 $legend_arr[ $key ] .= ' <div class="date-content-top"></div>';
71 - $legend_arr[ $key ] .= ' <' . $day_cell_tag . '>' . $params['text_for_day_cell'] . '</' . $day_cell_tag . '>';
76 + $legend_arr[ $key ] .= ' <' . $day_cell_tag . '>' . esc_html( $params['text_for_day_cell'] ) . '</' . $day_cell_tag . '>';
72 77 $legend_arr[ $key ] .= ' <div class="date-content-bottom"></div>';
73 78 $legend_arr[ $key ] .= ' </div>';
74 79 $legend_arr[ $key ] .= '</div>';
75 80 $legend_arr[ $key ] .= '</td></tr></tbody></table>';
@@ -86,9 +91,9 @@
86 91 $legend_arr[ $key ] .= '<td class="datepick-days-cell datepick-unselectable date_user_unavailable full_day_booking date2approve wpbc_calendar_legend_day_cell_height">';
87 92 $legend_arr[ $key ] .= '<div class="wpbc-cell-box">';
88 93 $legend_arr[ $key ] .= ' <div class="date-cell-content">';
89 94 $legend_arr[ $key ] .= ' <div class="date-content-top"></div>';
90 - $legend_arr[ $key ] .= ' <' . $day_cell_tag . '>' . $params['text_for_day_cell'] . '</' . $day_cell_tag . '>';
95 + $legend_arr[ $key ] .= ' <' . $day_cell_tag . '>' . esc_html( $params['text_for_day_cell'] ) . '</' . $day_cell_tag . '>';
91 96 $legend_arr[ $key ] .= ' <div class="date-content-bottom"></div>';
92 97 $legend_arr[ $key ] .= ' </div>';
93 98 $legend_arr[ $key ] .= '</div>';
94 99 $legend_arr[ $key ] .= '</td></tr></tbody></table>';
@@ -105,9 +110,9 @@
105 110 $legend_arr[ $key ] .= '<td class="datepick-days-cell datepick-unselectable date_user_unavailable full_day_booking date_approved wpbc_calendar_legend_day_cell_height">';
106 111 $legend_arr[ $key ] .= '<div class="wpbc-cell-box">';
107 112 $legend_arr[ $key ] .= ' <div class="date-cell-content">';
108 113 $legend_arr[ $key ] .= ' <div class="date-content-top"></div>';
109 - $legend_arr[ $key ] .= ' <' . $day_cell_tag . '>' . $params['text_for_day_cell'] . '</' . $day_cell_tag . '>';
114 + $legend_arr[ $key ] .= ' <' . $day_cell_tag . '>' . esc_html( $params['text_for_day_cell'] ) . '</' . $day_cell_tag . '>';
110 115 $legend_arr[ $key ] .= ' <div class="date-content-bottom"></div>';
111 116 $legend_arr[ $key ] .= ' </div>';
112 117 $legend_arr[ $key ] .= '</div>';
113 118 $legend_arr[ $key ] .= '</td></tr></tbody></table>';
@@ -118,17 +123,23 @@
118 123 // Content for Partially booked item - "time slot" or "change over days".
119 124 if ( 1 ) {
120 125 $my_partially = '';
121 126
122 - $booking_timeslot_day_bg_as_available = ( 'On' === get_bk_option( 'booking_timeslot_day_bg_as_available' ) ) ? ' wpbc_timeslot_day_bg_as_available' : '';
123 - $booking_timeslot_day_bg_as_available .= ( 'Off' !== get_bk_option( 'booking_change_over_days_triangles' ) ) ? ' wpbc_change_over_triangle' : '';
127 + $booking_change_over_triangle = ( 'Off' !== get_bk_option( 'booking_change_over_days_triangles' ) ) ? ' wpbc_change_over_triangle' : '';
124 128
125 129
126 - $my_partially .= '<span class="' . $booking_timeslot_day_bg_as_available . '">';
130 + $my_partially .= '<span class="' . $booking_change_over_triangle . '">';
127 131 $my_partially .= '<div class="datepick-inline wpbc_calendar_legend_table_width_height">'; // FixIn: 9.3.1.4.
128 132 $my_partially .= '<table class="datepick wpbc_calendar" style=""><tbody><tr>';
129 - if ( ( function_exists( 'wpbc_is_booking_used_check_in_out_time' ) ) && ( wpbc_is_booking_used_check_in_out_time() ) ) { // FixIn: 8.9.4.10.
130 - $my_partially .= '<td class="datepick-days-cell date_available date_approved timespartly check_in_time check_in_time_date_approved wpbc_calendar_legend_day_cell_height">';
133 + $is_change_over_legend = null;
134 + if ( function_exists( 'wpbc_settings_calendar__preview_is_changeover_enabled' ) ) {
135 + $is_change_over_legend = wpbc_settings_calendar__preview_is_changeover_enabled( $params['resource_id'], false );
136 + }
137 + if ( null === $is_change_over_legend ) {
138 + $is_change_over_legend = ( function_exists( 'wpbc_is_booking_used_check_in_out_time' ) ) && ( wpbc_is_booking_used_check_in_out_time( false, $params['resource_id'] ) ); // FixIn: 8.9.4.10.
139 + }
140 + if ( $is_change_over_legend ) {
141 + $my_partially .= '<td class="datepick-days-cell date_available date_approved timespartly check_in_time check_out_time check_in_time_date_approved check_out_time_date2approve wpbc_calendar_legend_day_cell_height">';
131 142 } else {
132 143 $my_partially .= '<td class="datepick-days-cell date_available date2approve timespartly times_clock wpbc_calendar_legend_day_cell_height">';
133 144 }
134 145 $my_partially .= '<div class="wpbc-cell-box">';
@@ -137,9 +148,9 @@
137 148 $my_partially .= ' <div class="wpbc-co-in"><svg height="100%" width="100%" viewBox="0 0 98 98" preserveAspectRatio="none"><polygon points="0,99 99,99 99,0"></polygon><polygon points="50,98 98,98 98,0 50,0"></polygon></svg></div>';
138 149 $my_partially .= ' </div>';
139 150 $my_partially .= ' <div class="date-cell-content">';
140 151 $my_partially .= ' <div class="date-content-top"><div class="wpbc_time_dots">·</div></div>';
141 - $my_partially .= ' <a>' . $params['text_for_day_cell'] . '</a>';
152 + $my_partially .= ' <a>' . esc_html( $params['text_for_day_cell'] ) . '</a>';
142 153 $my_partially .= ' <div class="date-content-bottom"></div>';
143 154 $my_partially .= ' </div>';
144 155 $my_partially .= '</div>';
145 156 $my_partially .= '</td></tr></tbody></table>';
@@ -154,9 +165,9 @@
154 165 $my_unavailable .= '<td class="datepick-days-cell datepick-unselectable date_user_unavailable wpbc_calendar_legend_day_cell_height">';
155 166 $my_unavailable .= '<div class="wpbc-cell-box">';
156 167 $my_unavailable .= ' <div class="date-cell-content">';
157 168 $my_unavailable .= ' <div class="date-content-top"></div>';
158 - $my_unavailable .= ' <' . $params['unavailable_day_cell_tag'] . '>' . $params['text_for_day_cell'] . '</' . $params['unavailable_day_cell_tag'] . '>';
169 + $my_unavailable .= ' <' . $params['unavailable_day_cell_tag'] . '>' . esc_html( $params['text_for_day_cell'] ) . '</' . $params['unavailable_day_cell_tag'] . '>';
159 170 $my_unavailable .= ' <div class="date-content-bottom"></div>';
160 171 $my_unavailable .= ' </div>';
161 172 $my_unavailable .= '</div>';
162 173 $my_unavailable .= '</td></tr></tbody></table>';
@@ -162,10 +173,10 @@
162 173 $my_unavailable .= '</td></tr></tbody></table>';
163 174 $my_unavailable .= '</div>';
164 175 }
165 176
166 - // Resource Unavailable.
167 - if ( 1 ) {
177 + // Resource Unavailable.
178 + if ( 1 ) {
168 179 $my_resource_unavailable = '<div class="datepick-inline wpbc_calendar_legend_table_width_height">'; // FixIn: 9.3.1.4.
169 180 $my_resource_unavailable .= '<table class="datepick wpbc_calendar" style=""><tbody><tr>';
170 181 $my_resource_unavailable .= '<td class="datepick-days-cell resource_unavailable date_user_unavailable wpbc_calendar_legend_day_cell_height">';
171 182 $my_resource_unavailable .= '<div class="wpbc-cell-box">';
@@ -170,15 +181,47 @@
170 181 $my_resource_unavailable .= '<td class="datepick-days-cell resource_unavailable date_user_unavailable wpbc_calendar_legend_day_cell_height">';
171 182 $my_resource_unavailable .= '<div class="wpbc-cell-box">';
172 183 $my_resource_unavailable .= ' <div class="date-cell-content">';
173 184 $my_resource_unavailable .= ' <div class="date-content-top"></div>';
174 - $my_resource_unavailable .= ' <' . $params['unavailable_day_cell_tag'] . '>' . $params['text_for_day_cell'] . '</' . $params['unavailable_day_cell_tag'] . '>';
185 + $my_resource_unavailable .= ' <' . $params['unavailable_day_cell_tag'] . '>' . esc_html( $params['text_for_day_cell'] ) . '</' . $params['unavailable_day_cell_tag'] . '>';
175 186 $my_resource_unavailable .= ' <div class="date-content-bottom"></div>';
176 187 $my_resource_unavailable .= ' </div>';
177 188 $my_resource_unavailable .= '</div>';
178 189 $my_resource_unavailable .= '</td></tr></tbody></table>';
179 - $my_resource_unavailable .= '</div>';
180 - }
190 + $my_resource_unavailable .= '</div>';
191 + }
192 +
193 + // Some Resources unavailable in an aggregate calendar.
194 + if ( 1 ) {
195 + $my_resources_partially_unavailable = '<div class="datepick-inline wpbc_calendar_legend_table_width_height">';
196 + $my_resources_partially_unavailable .= '<table class="datepick wpbc_calendar" style=""><tbody><tr>';
197 + $my_resources_partially_unavailable .= '<td class="datepick-days-cell date_available wpbc_resources_partially_unavailable wpbc_calendar_legend_day_cell_height">';
198 + $my_resources_partially_unavailable .= '<div class="wpbc-cell-box">';
199 + $my_resources_partially_unavailable .= ' <div class="date-cell-content">';
200 + $my_resources_partially_unavailable .= ' <div class="date-content-top"></div>';
201 + $my_resources_partially_unavailable .= ' <span>' . esc_html( $params['text_for_day_cell'] ) . '</span>';
202 + $my_resources_partially_unavailable .= ' <div class="date-content-bottom"></div>';
203 + $my_resources_partially_unavailable .= ' </div>';
204 + $my_resources_partially_unavailable .= '</div>';
205 + $my_resources_partially_unavailable .= '</td></tr></tbody></table>';
206 + $my_resources_partially_unavailable .= '</div>';
207 + }
208 +
209 + // One or more Resources have bookings in an aggregate calendar.
210 + if ( 1 ) {
211 + $my_resources_have_bookings = '<div class="datepick-inline wpbc_calendar_legend_table_width_height">';
212 + $my_resources_have_bookings .= '<table class="datepick wpbc_calendar" style=""><tbody><tr>';
213 + $my_resources_have_bookings .= '<td class="datepick-days-cell date_available wpbc_resources_have_bookings wpbc_calendar_legend_day_cell_height">';
214 + $my_resources_have_bookings .= '<div class="wpbc-cell-box">';
215 + $my_resources_have_bookings .= ' <div class="date-cell-content">';
216 + $my_resources_have_bookings .= ' <div class="date-content-top"></div>';
217 + $my_resources_have_bookings .= ' <span>' . esc_html( $params['text_for_day_cell'] ) . '</span>';
218 + $my_resources_have_bookings .= ' <div class="date-content-bottom"></div>';
219 + $my_resources_have_bookings .= ' </div>';
220 + $my_resources_have_bookings .= '</div>';
221 + $my_resources_have_bookings .= '</td></tr></tbody></table>';
222 + $my_resources_have_bookings .= '</div>';
223 + }
181 224
182 225
183 226
184 227 $items_arr = array( 'available' => array(
@@ -217,14 +260,24 @@
217 260 )
218 261 , 'text_for_day_cell' => $my_unavailable
219 262 , 'css_class' => '' //'datepick-days-cell datepick-unselectable date_user_unavailable'
220 263 )
221 - , 'resource_unavailable' => array(
222 - 'title' => ( ! empty( $params['titles']['resource_unavailable'] ) ) ? $params['titles']['resource_unavailable'] : __( 'Resource unavailable days', 'booking' )
223 - , 'text_for_day_cell' => $my_resource_unavailable
224 - , 'css_class' => '' //'datepick-days-cell resource_unavailable date_user_unavailable'
225 - )
226 - );
264 + , 'resource_unavailable' => array(
265 + 'title' => ( ! empty( $params['titles']['resource_unavailable'] ) ) ? $params['titles']['resource_unavailable'] : __( 'Resource unavailable days', 'booking' )
266 + , 'text_for_day_cell' => $my_resource_unavailable
267 + , 'css_class' => '' //'datepick-days-cell resource_unavailable date_user_unavailable'
268 + )
269 + , 'resources_partially_unavailable' => array(
270 + 'title' => ( ! empty( $params['titles']['resources_partially_unavailable'] ) ) ? $params['titles']['resources_partially_unavailable'] : __( 'Some booking items unavailable', 'booking' )
271 + , 'text_for_day_cell' => $my_resources_partially_unavailable
272 + , 'css_class' => ''
273 + )
274 + , 'resources_have_bookings' => array(
275 + 'title' => ( ! empty( $params['titles']['resources_have_bookings'] ) ) ? $params['titles']['resources_have_bookings'] : __( 'Bookings exist for one or more booking items', 'booking' )
276 + , 'text_for_day_cell' => $my_resources_have_bookings
277 + , 'css_class' => ''
278 + )
279 + );
227 280
228 281 $calendar_legend_html = '<div class="block_hints datepick ' . ( ( $params['is_vertical'] ) ? ' block_hints_vertical ' : '' ) . '">';
229 282
230 283 foreach ( $params['items'] as $item_name ) {
@@ -232,9 +285,9 @@
232 285 if ( ! empty( $items_arr[ $item_name ] ) ) {
233 286 $calendar_legend_html .= '<div class="wpdev_hint_with_text">'
234 287 . '<div class="' . $items_arr[ $item_name ]['css_class'] . '">' . $items_arr[ $item_name ]['text_for_day_cell'] . '</div>'
235 288 . '<div class="block_text">' . '- ' . '</div>'
236 - . '<div class="block_text">' . $items_arr[ $item_name ]['title'] . '</div>'
289 + . '<div class="block_text">' . esc_html( $items_arr[ $item_name ]['title'] ) . '</div>'
237 290 . '</div>';
238 291 }
239 292 }
240 293
@@ -255,9 +308,9 @@
255 308 * Example of shortcode parameters:
256 309 * [legend_items items="available,unavailable,pending,approved,partially" text_for_day_cell="31"]
257 310 * [legend_items is_vertical="1"]
258 311 * [legend_items]
259 - * [legend_items items="resource_unavailable,available,unavailable,pending,approved,partially" text_for_day_cell="31" titles="resource_unavailable={Resource unavailable days} unavailable={Season unavailable}"]
312 + * [legend_items items="resource_unavailable,resources_partially_unavailable,resources_have_bookings,available,unavailable,pending,approved,partially" text_for_day_cell="31" titles="resource_unavailable={Resource unavailable days} unavailable={Season unavailable}"]
260 313 *
261 314 * PHP code example with escaping single and double quotes:
262 315 * echo wpbc_replace_shortcodes_in_booking_form__legend_items( '[legend_items'
263 316 . ' items="unavailable,available,pending,approved,partially"'
@@ -310,8 +363,9 @@
310 363 )
311 364 , 'unavailable_day_cell_tag' => ( ! empty( $shortcode_params['unavailable_day_cell_tag'] ) )
312 365 ? $shortcode_params['unavailable_day_cell_tag']
313 366 : 'span'
367 + , 'resource_id' => absint( $resource_id )
314 368 , 'titles' => $shortcode_titles_params
315 369 ) );
316 370
317 371 $return_form = substr( $return_form, 0, ( $shortcode_params['start'] - 1 ) )
@@ -322,5 +376,5 @@
322 376 }
323 377
324 378 return $return_form;
325 379 }
326 -add_filter( 'wpbc_replace_shortcodes_in_booking_form', 'wpbc_replace_shortcodes_in_booking_form__legend_items', 10, 3 );
380 +add_filter( 'wpbc_replace_shortcodes_in_booking_form', 'wpbc_replace_shortcodes_in_booking_form__legend_items', 10, 3 );