| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Functions |
| 5 |
* |
| 6 |
* @package AutomatorWP\BookingCalendar\Functions |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
|
| 13 |
/** |
| 14 |
* Options callback for select2 fields assigned to bookings |
| 15 |
* |
| 16 |
* @since 1.0.0 |
| 17 |
* |
| 18 |
* @param stdClass $field |
| 19 |
* |
| 20 |
* @return array |
| 21 |
*/ |
| 22 |
function automatorwp_wp_booking_calendar_options_cb_booking( $field ) { |
| 23 |
|
| 24 |
// Setup vars |
| 25 |
$value = $field->escaped_value; |
| 26 |
$none_value = 'any'; |
| 27 |
$none_label = __( 'any booking', 'automatorwp' ); |
| 28 |
$options = automatorwp_options_cb_none_option( $field, $none_value, $none_label ); |
| 29 |
|
| 30 |
if( ! empty( $value ) ) { |
| 31 |
if( ! is_array( $value ) ) { |
| 32 |
$value = array( $value ); |
| 33 |
} |
| 34 |
|
| 35 |
foreach( $value as $booking_id ) { |
| 36 |
|
| 37 |
// Skip option none |
| 38 |
if( $booking_id === $none_value ) { |
| 39 |
continue; |
| 40 |
} |
| 41 |
|
| 42 |
$options[$booking_id] = $booking_id; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
return $options; |
| 47 |
|
| 48 |
} |