Advertisement
Guest User

Trip detail customize

a guest
Jun 14th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. remove_action( 'wp_travel_single_trip_meta_list', 'wp_travel_single_location', 1 );
  2. add_action( 'wp_travel_single_trip_meta_list', 'wp_travel_single_location_customize', 1 );
  3.  
  4. function wp_travel_single_location_customize( $post_id ) {
  5.     if ( ! $post_id ) {
  6.         return;
  7.     }
  8.     $terms = get_the_terms( $post_id, 'travel_locations' );
  9.  
  10.    
  11.  
  12.     $fixed_departure = get_post_meta( $post_id, 'wp_travel_fixed_departure', true );
  13.     $fixed_departure = ( $fixed_departure ) ? $fixed_departure : 'yes';
  14.     $fixed_departure = apply_filters( 'wp_travel_fixed_departure_defalut', $fixed_departure );
  15.  
  16.     $trip_duration       = get_post_meta( $post_id, 'wp_travel_trip_duration', true );
  17.     $trip_duration       = ( $trip_duration ) ? $trip_duration : 0;
  18.     $trip_duration_night = get_post_meta( $post_id, 'wp_travel_trip_duration_night', true );
  19.     $trip_duration_night = ( $trip_duration_night ) ? $trip_duration_night : 0;
  20.     if ( is_array( $terms ) && count( $terms ) > 0 ) :
  21.         ?>
  22.         <li class="no-border">
  23.             <div class="travel-info">
  24.                 <strong class="title"><?php esc_html_e( 'Locations', 'wp-travel' ); ?></strong>
  25.             </div>
  26.             <div class="travel-info">
  27.                 <span class="value">
  28.                     <?php
  29.                     $i = 0;
  30.                     foreach ( $terms as $term ) :
  31.                         if ( $i > 0 ) :
  32.                             ?>
  33.                              ,
  34.                             <?php
  35.                         endif;
  36.                         ?>
  37.                         <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>
  38.                         <?php
  39.                         $i++;
  40.                     endforeach;
  41.                     ?>
  42.                 </span>
  43.             </div>
  44.         </li>
  45.     <?php endif; ?>
  46.     <?php if ( 'yes' === $fixed_departure ) :
  47.             if ( $dates = wp_travel_get_fixed_departure_date( $post_id ) ) {
  48.                 ?>
  49.                 <li>
  50.                     <div class="travel-info">
  51.                         <strong class="title"><?php esc_html_e( 'Next Departure', 'wp-travel' ); ?></strong>
  52.                     </div>
  53.                     <div class="travel-info">
  54.                         <span class="value">
  55.                             <?php echo $dates; ?>
  56.                         </span>
  57.                     </div>
  58.                 </li>
  59.                 <?php
  60.             }
  61.         ?>
  62.        
  63.     <?php else : ?>
  64.         <?php if ( $trip_duration || $trip_duration_night ) : ?>
  65.             <li>
  66.                 <div class="travel-info">
  67.                     <strong class="title"><?php esc_html_e( 'Trip Duration', 'wp-travel' ); ?></strong>
  68.                 </div>
  69.                 <div class="travel-info">
  70.                     <span class="value">
  71.                         <?php printf( __( '%1$s Day(s) %2$s Night(s)', 'wp-travel' ), $trip_duration, $trip_duration_night ); ?>
  72.                     </span>
  73.                 </div>
  74.             </li>
  75.         <?php endif; ?>
  76.         <?php
  77.     endif;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement