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 +69 -18 10.15.6 → 11.9 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2
3 3 if ( ! defined( 'ABSPATH' ) ) {
4 4 exit; // Exit if accessed directly.
@@ -11,9 +11,9 @@
11 11 * Get html content of " Calendar Legend Items " , based on General Settings configuration.
12 12 *
13 13 * @return string HTML content of legend items
14 14 */
15 -function wpbc_get_calendar_legend() {
15 +function wpbc_get_calendar_legend( $resource_id = 0 ) {
16 16
17 17 $calendar_legend_html = '';
18 18
19 19 if ( get_bk_option( 'booking_is_show_legend' ) == 'On' ) {
@@ -34,8 +34,9 @@
34 34 $calendar_legend_html = wpbc_get_calendar_legend__content_html( array(
35 35 'is_vertical' => ( 'On' != get_bk_option( 'booking_legend_is_vertical' ) ) ? false : true
36 36 , 'text_for_day_cell' => ( 'On' != get_bk_option( 'booking_legend_is_show_numbers' ) ) ? '&nbsp;' : gmdate( 'd' )
37 37 , 'items' => $items_sort
38 + , 'resource_id' => absint( $resource_id )
38 39 ) );
39 40 }
40 41
41 42 return $calendar_legend_html;
@@ -53,8 +54,9 @@
53 54 , 'pending'
54 55 , 'partially'
55 56 )
56 57 , 'unavailable_day_cell_tag' => 'span'
58 + , 'resource_id' => 0
57 59 , 'titles' => array()
58 60 );
59 61 $params = wp_parse_args( $params, $defaults );
60 62
@@ -121,17 +123,23 @@
121 123 // Content for Partially booked item - "time slot" or "change over days".
122 124 if ( 1 ) {
123 125 $my_partially = '';
124 126
125 - $booking_timeslot_day_bg_as_available = ( 'On' === get_bk_option( 'booking_timeslot_day_bg_as_available' ) ) ? ' wpbc_timeslot_day_bg_as_available' : '';
126 - $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' : '';
127 128
128 129
129 - $my_partially .= '<span class="' . $booking_timeslot_day_bg_as_available . '">';
130 + $my_partially .= '<span class="' . $booking_change_over_triangle . '">';
130 131 $my_partially .= '<div class="datepick-inline wpbc_calendar_legend_table_width_height">'; // FixIn: 9.3.1.4.
131 132 $my_partially .= '<table class="datepick wpbc_calendar" style=""><tbody><tr>';
132 - if ( ( function_exists( 'wpbc_is_booking_used_check_in_out_time' ) ) && ( wpbc_is_booking_used_check_in_out_time() ) ) { // FixIn: 8.9.4.10.
133 - $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">';
134 142 } else {
135 143 $my_partially .= '<td class="datepick-days-cell date_available date2approve timespartly times_clock wpbc_calendar_legend_day_cell_height">';
136 144 }
137 145 $my_partially .= '<div class="wpbc-cell-box">';
@@ -165,10 +173,10 @@
165 173 $my_unavailable .= '</td></tr></tbody></table>';
166 174 $my_unavailable .= '</div>';
167 175 }
168 176
169 - // Resource Unavailable.
170 - if ( 1 ) {
177 + // Resource Unavailable.
178 + if ( 1 ) {
171 179 $my_resource_unavailable = '<div class="datepick-inline wpbc_calendar_legend_table_width_height">'; // FixIn: 9.3.1.4.
172 180 $my_resource_unavailable .= '<table class="datepick wpbc_calendar" style=""><tbody><tr>';
173 181 $my_resource_unavailable .= '<td class="datepick-days-cell resource_unavailable date_user_unavailable wpbc_calendar_legend_day_cell_height">';
174 182 $my_resource_unavailable .= '<div class="wpbc-cell-box">';
@@ -178,10 +186,42 @@
178 186 $my_resource_unavailable .= ' <div class="date-content-bottom"></div>';
179 187 $my_resource_unavailable .= ' </div>';
180 188 $my_resource_unavailable .= '</div>';
181 189 $my_resource_unavailable .= '</td></tr></tbody></table>';
182 - $my_resource_unavailable .= '</div>';
183 - }
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 + }
184 224
185 225
186 226
187 227 $items_arr = array( 'available' => array(
@@ -220,14 +260,24 @@
220 260 )
221 261 , 'text_for_day_cell' => $my_unavailable
222 262 , 'css_class' => '' //'datepick-days-cell datepick-unselectable date_user_unavailable'
223 263 )
224 - , 'resource_unavailable' => array(
225 - 'title' => ( ! empty( $params['titles']['resource_unavailable'] ) ) ? $params['titles']['resource_unavailable'] : __( 'Resource unavailable days', 'booking' )
226 - , 'text_for_day_cell' => $my_resource_unavailable
227 - , 'css_class' => '' //'datepick-days-cell resource_unavailable date_user_unavailable'
228 - )
229 - );
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 + );
230 280
231 281 $calendar_legend_html = '<div class="block_hints datepick ' . ( ( $params['is_vertical'] ) ? ' block_hints_vertical ' : '' ) . '">';
232 282
233 283 foreach ( $params['items'] as $item_name ) {
@@ -258,9 +308,9 @@
258 308 * Example of shortcode parameters:
259 309 * [legend_items items="available,unavailable,pending,approved,partially" text_for_day_cell="31"]
260 310 * [legend_items is_vertical="1"]
261 311 * [legend_items]
262 - * [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}"]
263 313 *
264 314 * PHP code example with escaping single and double quotes:
265 315 * echo wpbc_replace_shortcodes_in_booking_form__legend_items( '[legend_items'
266 316 . ' items="unavailable,available,pending,approved,partially"'
@@ -313,8 +363,9 @@
313 363 )
314 364 , 'unavailable_day_cell_tag' => ( ! empty( $shortcode_params['unavailable_day_cell_tag'] ) )
315 365 ? $shortcode_params['unavailable_day_cell_tag']
316 366 : 'span'
367 + , 'resource_id' => absint( $resource_id )
317 368 , 'titles' => $shortcode_titles_params
318 369 ) );
319 370
320 371 $return_form = substr( $return_form, 0, ( $shortcode_params['start'] - 1 ) )
@@ -325,5 +376,5 @@
325 376 }
326 377
327 378 return $return_form;
328 379 }
329 -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 );