Advertisement
Guest User

wp-travel-customize

a guest
Nov 11th, 2018
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.71 KB | None | 0 0
  1. remove_action( 'wp_travel_single_itinerary_after_trip_meta_list', 'wp_travel_single_location', 1 );
  2.  
  3.  
  4. add_action( 'wp_travel_single_itinerary_after_trip_meta_list', 'wp_travel_child_single_location', 1 );
  5.  
  6. function wp_travel_child_single_location( $post_id ) {
  7.     if ( ! $post_id ) {
  8.         return;
  9.     }
  10.     $terms = get_the_terms( $post_id, 'travel_locations' );
  11.  
  12.     $start_date = get_post_meta( $post_id, 'wp_travel_start_date', true );
  13.     $end_date   = get_post_meta( $post_id, 'wp_travel_end_date', true );
  14.  
  15.     $fixed_departure = get_post_meta( $post_id, 'wp_travel_fixed_departure', true );
  16.     $fixed_departure = ( $fixed_departure ) ? $fixed_departure : 'yes';
  17.     $fixed_departure = apply_filters( 'wp_travel_fixed_departure_defalut', $fixed_departure );
  18.  
  19.     $trip_duration = get_post_meta( $post_id, 'wp_travel_trip_duration', true );
  20.     $trip_duration = ( $trip_duration ) ? $trip_duration : 0;
  21.     $trip_duration_night = get_post_meta( $post_id, 'wp_travel_trip_duration_night', true );
  22.     $trip_duration_night = ( $trip_duration_night ) ? $trip_duration_night : 0;
  23.     if ( is_array( $terms ) && count( $terms ) > 0 ) : ?>
  24.         <li class="no-border">
  25.             <div class="travel-info">
  26.                 <strong class="title"><?php esc_html_e( 'Locations', 'wp-travel' ); ?></strong>
  27.             </div>
  28.             <div class="travel-info">
  29.                 <span class="value"><?php $i = 0; ?><?php foreach ( $terms as $term ) : ?><?php 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>
  30.             </div>
  31.         </li>
  32.     <?php endif; ?>
  33.         <li>
  34.             <?php if ( 'yes' === $fixed_departure ) : ?>
  35.                 <?php if ( $start_date && $end_date ) :  ?>
  36.                     <div class="travel-info">
  37.                         <strong class="title"><?php esc_html_e( 'YOUR TEXT', 'wp-travel' ); ?></strong>
  38.                     </div>
  39.                     <div class="travel-info">
  40.                         <span class="value">
  41.                             <?php $date_format = get_option( 'date_format' ); ?>
  42.                             <?php if ( ! $date_format ) : ?>
  43.                                 <?php $date_format = 'jS M, Y'; ?>
  44.                             <?php endif; ?>
  45.                             <?php printf( '%s - %s', date( $date_format, strtotime( $start_date ) ), date( $date_format, strtotime( $end_date ) ) ); ?>
  46.                         </span>
  47.                     </div>
  48.                 <?php endif; ?>
  49.             <?php else : ?>
  50.                 <?php if ( $trip_duration || $trip_duration_night ) : ?>
  51.                     <div class="travel-info">
  52.                         <strong class="title"><?php esc_html_e( 'Trip Duration', 'wp-travel' ); ?></strong>
  53.                     </div>
  54.                     <div class="travel-info">
  55.                         <span class="value">
  56.                             <?php printf( __( '%s Day(s) %s Night(s)', 'wp-travel' ), $trip_duration, $trip_duration_night ); ?>
  57.                         </span>
  58.                     </div>
  59.                 <?php endif; ?>
  60.  
  61.             <?php endif; ?>
  62.         </li>
  63.     <?php
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement