Advertisement
Guest User

functions.php

a guest
Aug 21st, 2019
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.44 KB | None | 0 0
  1. <?php
  2. // Exit if accessed directly
  3. if ( !defined( 'ABSPATH' ) ) exit;
  4.  
  5. // BEGIN ENQUEUE PARENT ACTION
  6. // AUTO GENERATED - Do not modify or remove comment markers above or below:
  7.  
  8. // END ENQUEUE PARENT ACTION
  9. //
  10.  
  11. /***** CHANGE FIXED DEP LABEL *****/
  12. remove_action( 'wp_travel_single_trip_meta_list', 'wp_travel_single_location' );
  13.  
  14.  
  15. add_action( 'wp_travel_single_trip_meta_list', 'wp_travel_child_single_location' );
  16.  
  17. function wp_travel_child_single_location( $post_id ) {
  18.     if ( ! $post_id ) {
  19.         return;
  20.     }
  21.     $terms = get_the_terms( $post_id, 'travel_locations' );
  22.  
  23.     $start_date = get_post_meta( $post_id, 'wp_travel_start_date', true );
  24.     $end_date   = get_post_meta( $post_id, 'wp_travel_end_date', true );
  25.  
  26.     $fixed_departure = get_post_meta( $post_id, 'wp_travel_fixed_departure', true );
  27.     $fixed_departure = ( $fixed_departure ) ? $fixed_departure : 'yes';
  28.     $fixed_departure = apply_filters( 'wp_travel_fixed_departure_defalut', $fixed_departure );
  29.  
  30.     $trip_duration = get_post_meta( $post_id, 'wp_travel_trip_duration', true );
  31.     $trip_duration = ( $trip_duration ) ? $trip_duration : 0;
  32.     $trip_duration_night = get_post_meta( $post_id, 'wp_travel_trip_duration_night', true );
  33.     $trip_duration_night = ( $trip_duration_night ) ? $trip_duration_night : 0;
  34.      ?>
  35.         <?php if ( 'yes' === $fixed_departure ) : ?>
  36.             <?php if ( $start_date && $end_date ) :  ?>
  37.                 <li>
  38.                     <div class="travel-info">
  39.                         <strong class="title"><?php esc_html_e( 'Seasonal Rates', 'wp-travel' ); ?></strong>
  40.                     </div>
  41.                     <div class="travel-info">
  42.                         <span class="value">
  43.                             <?php $date_format = get_option( 'date_format' ); ?>
  44.                             <?php if ( ! $date_format ) : ?>
  45.                                 <?php $date_format = 'jS M, Y'; ?>
  46.                             <?php endif; ?>
  47.                             <?php printf( '%s - %s', date( $date_format, strtotime( $start_date ) ), date( $date_format, strtotime( $end_date ) ) ); ?>
  48.                         </span>
  49.                     </div>
  50.                 </li>
  51.             <?php endif; ?>
  52.         <?php else : ?>
  53.             <?php if ( $trip_duration || $trip_duration_night ) : ?>
  54.                 <li>
  55.                     <div class="travel-info">
  56.                         <strong class="title"><?php esc_html_e( 'Trip Duration', 'wp-travel' ); ?></strong>
  57.                     </div>
  58.                     <div class="travel-info">
  59.                         <span class="value">
  60.                             <?php printf( __( '%s Day(s) %s Night(s)', 'wp-travel' ), $trip_duration, $trip_duration_night ); ?>
  61.                         </span>
  62.                     </div>
  63.                 </li>
  64.             <?php endif; ?>
  65.  
  66.         <?php endif; ?>
  67.         <li>
  68.             <div class="travel-info">
  69.               <strong class="title">Experiences Dates</strong>
  70.             </div>
  71.             <div class="travel-info">
  72.               <span class="value">
  73.               Check the calendar under the Booking Tab. If there's no date available: click on "Trip enquiry"
  74.               </span>
  75.             </div>
  76.           </li>
  77.     <?php
  78.  
  79. }
  80.  
  81. /***** END CHANGE FIXED DEP LABEL *****/
  82.  
  83. /**** Additional Info on single trip page ****/
  84. function wp_travel_travel_info_customize(){
  85. ?>
  86.  
  87. <?php
  88. }
  89.  
  90. // add_action('wp_travel_single_trip_meta_list','wp_travel_travel_info_customize');
  91. /**** End Additional Info on single trip page ****/
  92.  
  93. /******** SHOW BOOKING PAYMENT ONLY ON CART ********/
  94.  
  95. function wp_travel_customize_booking_option($fields){  
  96.  
  97.     $fields['payment_fields']['booking_option'] = array(
  98.         'type' => 'select',
  99.         'label' => 'Booking Options',
  100.         'name' => 'wp_travel_booking_option',
  101.         'id' => 'wp-travel-option',
  102.         'validations' => array(
  103.             'required' => 1
  104.         ),
  105.  
  106.         'options' => array('booking_payment_only' => 'Booking payment only' ),
  107.         'default' => 'booking_payment_only',
  108.  
  109.         'priority' => 100
  110.  
  111.  
  112.  
  113.     );
  114.    
  115.     return $fields;
  116. }
  117. add_filter( 'wp_travel_checkout_fields', 'wp_travel_customize_booking_option' );
  118.  
  119. /******** SHOW BOOKING PAYMENT ONLY ON CART END ********/
  120.  
  121. /******** CHANGE TEXT ON PLACEHOLDER ********/
  122.  
  123. function wp_travel_child_search_placeholder_text(){
  124.  
  125.     return esc_html__( 'Ex: Walking tour', 'wp-travel' );
  126. }
  127. add_filter('wp_travel_search_placeholder','wp_travel_child_search_placeholder_text');
  128.  
  129. /******** CHANGE TEXT ON PLACEHOLDER END ********/
  130.  
  131. /******** TRIP LISTING VIEW MODE **********/
  132.  
  133. add_filter( 'wp_travel_default_view_mode', 'default_view_mode' );
  134.  
  135. function default_view_mode( $view_mode ) {
  136.    
  137.     return 'grid';
  138. }
  139.  
  140. /******** TRIP LISTING VIEW MODE END **********/
  141.  
  142. /******** PAX TEXT ********/
  143.  
  144. function wp_travel_customize_travel_info_section (){
  145.  
  146. return __( '%d People max', 'wp-travel' );
  147. }
  148. add_filter ('wp_travel_template_group_size_text','wp_travel_customize_travel_info_section');
  149.  
  150. /******** PAX TEXT END ********/
  151.  
  152. /***** default country in form field *****/
  153.  
  154. function wp_travel_customize_default_country_setting(){
  155. ?>
  156.  
  157.   <script type="text/javascript">
  158.  
  159.   jQuery(document).ready(function(){
  160.  
  161.     jQuery('#wp-travel-country > option[value="US"]').attr("selected",true);
  162.  
  163.   });
  164.   </script>
  165.  
  166. <?php
  167.  
  168. }
  169. add_action( 'wp_footer', 'wp_travel_customize_default_country_setting', 20 );
  170.  
  171. /***** default country in form field end *****/
  172.  
  173. /**** Remove Categories Pre-Title ****/
  174.  
  175. function wp_travel_child_remove_cat_titles($title) {
  176.  
  177.     if ( is_archive() ) {
  178.  
  179.         $title = single_cat_title( '', false );
  180.  
  181.     } elseif ( is_tag() ) {
  182.  
  183.         $title = single_tag_title( '', false );
  184.  
  185.     } elseif ( is_author() ) {
  186.  
  187.         $title = '<span class="vcard">' . get_the_author() . '</span>' ;
  188.  
  189.     }
  190.  
  191.     return $title;
  192.  
  193. }
  194.  
  195. add_filter( 'get_the_archive_title', 'wp_travel_child_remove_cat_titles' );
  196.  
  197. /**** End Remove Categories Pre-Title ****/
  198.  
  199. /**** FROM added to price ****/
  200.  
  201. function wp_travel_customize_sale_price_display( $s, $c, $d ) {
  202.    
  203.    
  204.     return sprintf( esc_html__('From %1s %2s', 'wp-travel' ), $c , $d );
  205. }
  206. add_filter( 'wp_travel_itinerary_sale_price', 'wp_travel_customize_sale_price_display', 99, 3 );
  207. function wp_travel_customize_price_display( $s, $c, $d ) {
  208. global $wp_travel_itinerary;
  209. if ( $wp_travel_itinerary && $wp_travel_itinerary->is_sale_enabled() ) {
  210. return sprintf( esc_html__('From %1s %2s', 'wp-travel' ), $c , $d );
  211. // return $s;
  212. }
  213. return sprintf( esc_html__('From %1s %2s', 'wp-travel' ), $c , $d );
  214. }
  215. add_filter( 'wp_travel_itinerary_price', 'wp_travel_customize_price_display', 99, 3 );
  216.  
  217. function wp_travel_trip_price_customize( $post_id, $hide_rating = false ) {
  218.     $settings = wp_travel_get_settings();
  219.     $trip_price     = wp_travel_get_trip_price( $post_id );
  220.     $enable_sale    = get_post_meta( $post_id, 'wp_travel_enable_sale', true );
  221.     $sale_price     = wp_travel_get_trip_sale_price( $post_id );
  222.     $currency_code  = ( isset( $settings['currency'] ) ) ? $settings['currency'] : '';
  223.     $currency_symbol = wp_travel_get_currency_symbol( $currency_code );
  224.     $per_person_text = wp_travel_get_price_per_text( $post_id );
  225.     // $wp_travel_itinerary = new WP_Travel_Itinerary();
  226.     ?>
  227.     <div class="wp-detail-review-wrap">
  228.         <?php do_action( 'wp_travel_single_before_trip_price', $post_id, $hide_rating ); ?>
  229.         <div class="wp-travel-trip-detail">    
  230.         <?php if ( '' != $trip_price || '0' != $trip_price ) : ?>
  231.             <div class="trip-price" >
  232.             <?php if ( $enable_sale ) : ?>
  233.                 <del>
  234.                     <span><?php echo apply_filters( 'wp_travel_itinerary_price', sprintf( ' %s %s ', $currency_symbol, $trip_price ), $currency_symbol, $trip_price ); ?></span>
  235.                 </del>
  236.             <?php endif; ?>
  237.                 <span class="person-count">
  238.                     <ins>
  239.                         <span>
  240.                             <?php
  241.                             if ( $enable_sale ) {
  242.                                 echo apply_filters( 'wp_travel_itinerary_sale_price', sprintf( ' %s %s', $currency_symbol, $sale_price ), $currency_symbol, $sale_price );
  243.                             } else {
  244.                                 echo apply_filters( 'wp_travel_itinerary_price', sprintf( ' %s %s ', $currency_symbol, $trip_price ), $currency_symbol, $trip_price );
  245.                             }
  246.                             ?>
  247.                         </span>
  248.                     </ins>  
  249.                     <?php if ( ! empty( $per_person_text ) ) : ?>
  250.                         /<?php echo esc_html( $per_person_text ); ?>
  251.                     <?php endif; ?>                
  252.                 </span>
  253.             </div>
  254.         <?php endif; ?>
  255.         </div>
  256.         <?php do_action( 'wp_travel_single_after_trip_price', $post_id, $hide_rating ); ?>
  257.     </div>
  258. <?php
  259. }
  260. remove_action(  'wp_travel_single_trip_after_title', 'wp_travel_trip_price', 1 );
  261. add_action( 'wp_travel_single_trip_after_title', 'wp_travel_trip_price_customize', 0 );
  262.  
  263. /**** end FROM added to price ****/
  264.  
  265.  
  266. /**** Fixed Dep Title Text change on single trip page ****/
  267.  
  268. remove_action( 'wp_travel_single_trip_meta_list', 'wp_travel_single_location', 1 );
  269. add_action( 'wp_travel_single_trip_meta_list', 'wp_travel_single_location_customize', 1 );
  270.  
  271. function wp_travel_single_location_customize( $post_id ) {
  272.     if ( ! $post_id ) {
  273.         return;
  274.     }
  275.     $terms = get_the_terms( $post_id, 'travel_locations' );
  276.  
  277.    
  278.  
  279.     $fixed_departure = get_post_meta( $post_id, 'wp_travel_fixed_departure', true );
  280.     $fixed_departure = ( $fixed_departure ) ? $fixed_departure : 'yes';
  281.     $fixed_departure = apply_filters( 'wp_travel_fixed_departure_defalut', $fixed_departure );
  282.  
  283.     $trip_duration       = get_post_meta( $post_id, 'wp_travel_trip_duration', true );
  284.     $trip_duration       = ( $trip_duration ) ? $trip_duration : 0;
  285.     $trip_duration_night = get_post_meta( $post_id, 'wp_travel_trip_duration_night', true );
  286.     $trip_duration_night = ( $trip_duration_night ) ? $trip_duration_night : 0;
  287.     if ( is_array( $terms ) && count( $terms ) > 0 ) :
  288.         ?>
  289.         <li class="no-border">
  290.             <div class="travel-info">
  291.                 <strong class="title"><?php esc_html_e( 'Locations', 'wp-travel' ); ?></strong>
  292.             </div>
  293.             <div class="travel-info">
  294.                 <span class="value">
  295.                     <?php
  296.                     $i = 0;
  297.                     foreach ( $terms as $term ) :
  298.                         if ( $i > 0 ) :
  299.                             ?>
  300.                              ,
  301.                             <?php
  302.                         endif;
  303.                         ?>
  304.                         <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>
  305.                         <?php
  306.                         $i++;
  307.                     endforeach;
  308.                     ?>
  309.                 </span>
  310.             </div>
  311.         </li>
  312.     <?php endif; ?>
  313.     <?php if ( 'yes' === $fixed_departure ) :
  314.             if ( $dates = wp_travel_get_fixed_departure_date( $post_id ) ) {
  315.                 ?>
  316.                 <li>
  317.                     <div class="travel-info">
  318.                         <strong class="title"><?php esc_html_e( 'Next Experience', 'wp-travel' ); ?></strong>
  319.                     </div>
  320.                     <div class="travel-info">
  321.                         <span class="value">
  322.                             <?php echo $dates; ?>
  323.                         </span>
  324.                     </div>
  325.                 </li>
  326.                 <?php
  327.             }
  328.         ?>
  329.        
  330.     <?php else : ?>
  331.         <?php if ( $trip_duration || $trip_duration_night ) : ?>
  332.             <li>
  333.                 <div class="travel-info">
  334.                     <strong class="title"><?php esc_html_e( 'Trip Duration', 'wp-travel' ); ?></strong>
  335.                 </div>
  336.                 <div class="travel-info">
  337.                     <span class="value">
  338.                         <?php printf( __( '%1$s Day(s) %2$s Night(s)', 'wp-travel' ), $trip_duration, $trip_duration_night ); ?>
  339.                     </span>
  340.                 </div>
  341.             </li>
  342.         <?php endif; ?>
  343.         <?php
  344.     endif;
  345. }
  346. /**** End Fixed Dep Title Text change on single trip page ****/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement