|
@@ -1,4 +1,4 @@ |
|
1
|
1
|
<?php
|
|
2
|
2
|
/**
|
|
3
|
3
|
* @version 1.0
|
|
4
|
4
|
* @description Booking Calendar integration - Import bookings from ICS events
|
|
@@ -433,10 +433,10 @@ |
|
433
|
433
|
break;
|
|
434
|
434
|
}
|
|
435
|
435
|
}
|
|
436
|
436
|
|
|
437
|
|
- // Email.
|
|
438
|
|
- $email = '[email protected]'; //get_option ( 'admin_email' );
|
|
437
|
+ // Email
|
|
438
|
+ $email = '[email protected]'; //get_option ( 'admin_email' );
|
|
439
|
439
|
if ( ! empty( $ics_event['_BOOKING_ATTENDEE'] ) ) {
|
|
440
|
440
|
$email = str_replace( 'mailto:', '', $ics_event['_BOOKING_ATTENDEE'] );
|
|
441
|
441
|
if ( ! is_email( $email ) ) {
|
|
442
|
442
|
$email = '[email protected]';
|
|
@@ -441,10 +441,9 @@ |
|
441
|
441
|
if ( ! is_email( $email ) ) {
|
|
442
|
442
|
$email = '[email protected]';
|
|
443
|
443
|
}
|
|
444
|
444
|
}
|
|
445
|
|
- $email = apply_filters( 'wpbm_replace_mailto_for__booking_attendee', $email );
|
|
446
|
|
- $bk_data ['email'] = array( 'value' => $email, 'type' => 'email' );
|
|
445
|
+ $bk_data [ 'email' ] = array( 'value' => $email, 'type' => 'email' );
|
|
447
|
446
|
|
|
448
|
447
|
// Optional Start and End times
|
|
449
|
448
|
$start_time = substr( $ics_event[ '_BOOKING_DATES' ][ 0 ], 11 );
|
|
450
|
449
|
$end_time = $ics_event[ '_BOOKING_DATES' ][ ( count( $ics_event[ '_BOOKING_DATES' ] ) - 1 ) ];
|
|
@@ -1091,58 +1090,58 @@ |
|
1091
|
1090
|
return $bk_array;
|
|
1092
|
1091
|
}
|
|
1093
|
1092
|
|
|
1094
|
1093
|
|
|
1095
|
|
-/**
|
|
1096
|
|
- * Return existing non-trashed Booking Calendar synchronization UIDs.
|
|
1097
|
|
- *
|
|
1098
|
|
- * Event UIDs originate in remote iCalendar content. Each UID is therefore
|
|
1099
|
|
- * bound through a separate SQL placeholder instead of being interpolated into
|
|
1100
|
|
- * the dynamic IN clause.
|
|
1101
|
|
- *
|
|
1102
|
|
- * @global wpdb $wpdb WordPress database abstraction object.
|
|
1103
|
|
- *
|
|
1104
|
|
- * @param array $uid_arr Event UIDs to check.
|
|
1105
|
|
- *
|
|
1106
|
|
- * @return array Existing synchronization UIDs.
|
|
1107
|
|
- */
|
|
1108
|
|
-function wpbm_get_exist_bookings_gid( $uid_arr ) {
|
|
1109
|
|
- if ( empty( $uid_arr ) || ! is_array( $uid_arr ) ) {
|
|
1110
|
|
- return array();
|
|
1111
|
|
- }
|
|
1112
|
|
-
|
|
1113
|
|
- $uid_values = array();
|
|
1114
|
|
- foreach ( $uid_arr as $uid_value ) {
|
|
1115
|
|
- if ( ! is_scalar( $uid_value ) ) {
|
|
1116
|
|
- continue;
|
|
1117
|
|
- }
|
|
1118
|
|
-
|
|
1119
|
|
- $uid_values[] = (string) $uid_value;
|
|
1120
|
|
- }
|
|
1121
|
|
-
|
|
1122
|
|
- if ( empty( $uid_values ) ) {
|
|
1123
|
|
- return array();
|
|
1124
|
|
- }
|
|
1125
|
|
-
|
|
1126
|
|
- global $wpdb;
|
|
1127
|
|
-
|
|
1128
|
|
- $uid_placeholders = implode( ', ', array_fill( 0, count( $uid_values ), '%s' ) );
|
|
1129
|
|
- $query_values = array_merge( $uid_values, array( 1 ) );
|
|
1130
|
|
-
|
|
1131
|
|
- // The placeholder list contains only fixed %s tokens; the table name uses WordPress's trusted prefix.
|
|
1132
|
|
- $sql = $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
|
|
1133
|
|
- "SELECT sync_gid FROM {$wpdb->prefix}booking WHERE sync_gid IN ({$uid_placeholders}) AND trash != %d",
|
|
1134
|
|
- $query_values
|
|
1135
|
|
- );
|
|
1136
|
|
-
|
|
1137
|
|
- if ( ! is_string( $sql ) ) {
|
|
1138
|
|
- return array();
|
|
1139
|
|
- }
|
|
1140
|
|
-
|
|
1141
|
|
- $existing_booking_uids = $wpdb->get_col( $sql );
|
|
1142
|
|
-
|
|
1143
|
|
- return is_array( $existing_booking_uids ) ? $existing_booking_uids : array();
|
|
1144
|
|
-}
|
|
1094
|
+/** |
|
1095
|
+ * Return existing non-trashed Booking Calendar synchronization UIDs. |
|
1096
|
+ * |
|
1097
|
+ * Event UIDs originate in remote iCalendar content. Each UID is therefore |
|
1098
|
+ * bound through a separate SQL placeholder instead of being interpolated into |
|
1099
|
+ * the dynamic IN clause. |
|
1100
|
+ * |
|
1101
|
+ * @global wpdb $wpdb WordPress database abstraction object. |
|
1102
|
+ * |
|
1103
|
+ * @param array $uid_arr Event UIDs to check. |
|
1104
|
+ * |
|
1105
|
+ * @return array Existing synchronization UIDs. |
|
1106
|
+ */ |
|
1107
|
+function wpbm_get_exist_bookings_gid( $uid_arr ) { |
|
1108
|
+ if ( empty( $uid_arr ) || ! is_array( $uid_arr ) ) { |
|
1109
|
+ return array(); |
|
1110
|
+ } |
|
1111
|
+ |
|
1112
|
+ $uid_values = array(); |
|
1113
|
+ foreach ( $uid_arr as $uid_value ) { |
|
1114
|
+ if ( ! is_scalar( $uid_value ) ) { |
|
1115
|
+ continue; |
|
1116
|
+ } |
|
1117
|
+ |
|
1118
|
+ $uid_values[] = (string) $uid_value; |
|
1119
|
+ } |
|
1120
|
+ |
|
1121
|
+ if ( empty( $uid_values ) ) { |
|
1122
|
+ return array(); |
|
1123
|
+ } |
|
1124
|
+ |
|
1125
|
+ global $wpdb; |
|
1126
|
+ |
|
1127
|
+ $uid_placeholders = implode( ', ', array_fill( 0, count( $uid_values ), '%s' ) ); |
|
1128
|
+ $query_values = array_merge( $uid_values, array( 1 ) ); |
|
1129
|
+ |
|
1130
|
+ // The placeholder list contains only fixed %s tokens; the table name uses WordPress's trusted prefix. |
|
1131
|
+ $sql = $wpdb->prepare( // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
1132
|
+ "SELECT sync_gid FROM {$wpdb->prefix}booking WHERE sync_gid IN ({$uid_placeholders}) AND trash != %d", |
|
1133
|
+ $query_values |
|
1134
|
+ ); |
|
1135
|
+ |
|
1136
|
+ if ( ! is_string( $sql ) ) { |
|
1137
|
+ return array(); |
|
1138
|
+ } |
|
1139
|
+ |
|
1140
|
+ $existing_booking_uids = $wpdb->get_col( $sql ); |
|
1141
|
+ |
|
1142
|
+ return is_array( $existing_booking_uids ) ? $existing_booking_uids : array(); |
|
1143
|
+} |
|
1145
|
1144
|
|
|
1146
|
1145
|
|
|
1147
|
1146
|
/** Trim number of events in array
|
|
1148
|
1147
|
*
|