| @@ -5,9 +5,9 @@ | ||
| 5 | 5 | * @subpackage Import / Export ICS |
| 6 | 6 | * @category ICS |
| 7 | 7 | * |
| 8 | 8 | * @author wpdevelop |
| 9 | - * @link http://oplugins.com/ | |
| 9 | + * @link https://oplugins.com/ | |
| 10 | 10 | * @email [email protected] |
| 11 | 11 | * |
| 12 | 12 | * @modified 2017-03-01 |
| 13 | 13 | */ |
| @@ -184,10 +184,10 @@ | ||
| 184 | 184 | |
| 185 | 185 | /////////////////////////////////////////////////////////////// |
| 186 | 186 | // Listing Template |
| 187 | 187 | /////////////////////////////////////////////////////////////// |
| 188 | - $row_template = get_wpbm_option( 'wpbm_listing_template' ); | |
| 189 | - | |
| 188 | + $row_template = wpbm_sanitize_listing_template( get_wpbm_option( 'wpbm_listing_template' ) ); | |
| 189 | + | |
| 190 | 190 | // Normilize |
| 191 | 191 | $replace_array = array(); |
| 192 | 192 | foreach ( $evnt as $key => $value ) { |
| 193 | 193 | $key = str_replace( '_BOOKING_', '', $key ); |
| @@ -195,42 +195,68 @@ | ||
| 195 | 195 | $value = implode( ',', $value ); |
| 196 | 196 | $replace_array[ $key ] = $value; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | + //FixIn: 2.0.11.4 | |
| 200 | + if (function_exists('wpbc_get_bookings_url')) { | |
| 201 | + | |
| 202 | + $my_booking_id = wpbm_get_booking_id_by_UID( $replace_array['UID'] ); | |
| 203 | + $replace_array['BOOKING_ID'] = $my_booking_id; | |
| 204 | + | |
| 205 | + //FixIn: 2.0.11.5 | |
| 206 | + $replace_array['BOOKING_LINK'] = htmlspecialchars_decode( | |
| 207 | + // '<a href="' . | |
| 208 | + esc_url( wpbc_get_bookings_url() . '&tab=vm_booking_listing&wh_booking_id=' . $my_booking_id ) | |
| 209 | + // . '">' . __('here', 'booking') . '</a>' | |
| 210 | + ); | |
| 211 | + } | |
| 212 | + | |
| 213 | + //FixIn: 2.0.6.1 - Set timezone frrom Booking > Settings > Sync page for booking listing shortcode | |
| 214 | + $tzid = get_bk_option( 'booking_gcal_timezone' ); | |
| 215 | + if ( ! empty( $tzid ) ) { | |
| 216 | + $dates_array = explode( ',', $replace_array['DATES'] ); | |
| 217 | + foreach ( $dates_array as $dk => $day ) { | |
| 218 | + //$dates_array[ $dk ] = ZDateHelper::toLocalDateTime( get_gmt_from_date( $day ), $tzid ); | |
| 219 | + //debuge($day); | |
| 220 | + $dates_array[ $dk ] = ZDateHelper::toLocalDateTime( $day, $tzid ); | |
| 221 | + } | |
| 222 | + $replace_array['DATES'] = implode( ',', $dates_array ); | |
| 223 | + } | |
| 224 | + | |
| 199 | 225 | if ( ! empty( $replace_array['DATES'] ) ) |
| 200 | 226 | $replace_array['DATES'] = wpbm_get_dates_short_format( $replace_array['DATES'] ); |
| 201 | - | |
| 227 | + | |
| 202 | 228 | $echo_row = wpbm_replace_shortcodes( $row_template, $replace_array ); |
| 203 | - | |
| 229 | + | |
| 204 | 230 | return $echo_row; |
| 205 | 231 | } |
| 206 | 232 | |
| 207 | 233 | |
| 208 | - | |
| 234 | + | |
| 209 | 235 | /** Sort events by Check In days |
| 210 | - * | |
| 236 | + * | |
| 211 | 237 | * @param array $ics_events_arr |
| 212 | 238 | * @param string $sort_key - Default: '_BOOKING_DATES' |
| 213 | 239 | * @return array |
| 214 | - */ | |
| 240 | + */ | |
| 215 | 241 | function wpbm_sort_events_by( $ics_events_arr, $sort_key = '_BOOKING_DATES' ) { |
| 216 | - | |
| 242 | + | |
| 217 | 243 | // Get array with check in date |
| 218 | - $check_in_arr = array(); | |
| 244 | + $check_in_arr = array(); | |
| 219 | 245 | foreach ( $ics_events_arr as $key => $event_arr) { |
| 220 | 246 | $event_dates = $event_arr[ $sort_key ]; |
| 221 | 247 | sort( $event_dates ); |
| 222 | 248 | $check_in_arr[ $key ] = $event_dates[ 0 ]; |
| 223 | 249 | } |
| 224 | - | |
| 250 | + | |
| 225 | 251 | asort( $check_in_arr, SORT_STRING ); // Sort an array and maintain index association |
| 226 | - | |
| 252 | + | |
| 227 | 253 | // Sort inpur arr, by keys from previous check in array |
| 228 | 254 | $sorted_events_arr = array(); |
| 229 | 255 | foreach ( $check_in_arr as $key => $event_check_in) { |
| 230 | 256 | $sorted_events_arr[] = $ics_events_arr[ $key ]; |
| 231 | 257 | } |
| 232 | - | |
| 258 | + | |
| 233 | 259 | return $sorted_events_arr; |
| 234 | 260 | } |
| 235 | 261 | |
| 236 | 262 | |
| @@ -235,5 +261,5 @@ | ||
| 235 | 261 | |
| 236 | 262 | |
| 237 | 263 | |
| 238 | 264 | // TODO: |
| 239 | -// - list events by days and not events ??? currently if (0) {...} | |
| 265 | +// - list events by days and not events ??? currently if (0) {...} | |