Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- remove_action( 'wp_travel_single_trip_meta_list', 'wp_travel_single_location', 1 );
- add_action( 'wp_travel_single_trip_meta_list', 'wp_travel_single_location_customize', 1 );
- function wp_travel_single_location_customize( $post_id ) {
- if ( ! $post_id ) {
- return;
- }
- $terms = get_the_terms( $post_id, 'travel_locations' );
- $fixed_departure = get_post_meta( $post_id, 'wp_travel_fixed_departure', true );
- $fixed_departure = ( $fixed_departure ) ? $fixed_departure : 'yes';
- $fixed_departure = apply_filters( 'wp_travel_fixed_departure_defalut', $fixed_departure );
- $trip_duration = get_post_meta( $post_id, 'wp_travel_trip_duration', true );
- $trip_duration = ( $trip_duration ) ? $trip_duration : 0;
- $trip_duration_night = get_post_meta( $post_id, 'wp_travel_trip_duration_night', true );
- $trip_duration_night = ( $trip_duration_night ) ? $trip_duration_night : 0;
- if ( is_array( $terms ) && count( $terms ) > 0 ) :
- ?>
- <li class="no-border">
- <div class="travel-info">
- <strong class="title"><?php esc_html_e( 'Locations', 'wp-travel' ); ?></strong>
- </div>
- <div class="travel-info">
- <span class="value">
- <?php
- $i = 0;
- foreach ( $terms as $term ) :
- if ( $i > 0 ) :
- ?>
- ,
- <?php
- endif;
- ?>
- <span class="wp-travel-locations"><a href="<?php echo esc_url( get_term_link( $term->term_id ) ); ?>"><?php echo esc_html( $term->name ); ?></a></span>
- <?php
- $i++;
- endforeach;
- ?>
- </span>
- </div>
- </li>
- <?php endif; ?>
- <?php if ( 'yes' === $fixed_departure ) :
- if ( $dates = wp_travel_get_fixed_departure_date( $post_id ) ) {
- ?>
- <li>
- <div class="travel-info">
- <strong class="title"><?php esc_html_e( 'Next Departure', 'wp-travel' ); ?></strong>
- </div>
- <div class="travel-info">
- <span class="value">
- <?php echo $dates; ?>
- </span>
- </div>
- </li>
- <?php
- }
- ?>
- <?php else : ?>
- <?php if ( $trip_duration || $trip_duration_night ) : ?>
- <li>
- <div class="travel-info">
- <strong class="title"><?php esc_html_e( 'Trip Duration', 'wp-travel' ); ?></strong>
- </div>
- <div class="travel-info">
- <span class="value">
- <?php printf( __( '%1$s Day(s) %2$s Night(s)', 'wp-travel' ), $trip_duration, $trip_duration_night ); ?>
- </span>
- </div>
- </li>
- <?php endif; ?>
- <?php
- endif;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement