template-functions.php not working in theme

Homepage Forums WP Travel template-functions.php not working in theme

This topic contains 1 reply, has 2 voices, and was last updated by  wensolutions 6 days, 12 hours ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #21166

    karankcoresys
    Participant

    Hello

    I add template-functions.php in themes/my-theme/wp-travel/template-functions.php. But it’s not working, i want to put a class here (class=”wp-travel-tab-wrapper”) on this code:

    function wp_travel_frontend_contents( $post_id ) {
    	global $wp_travel_itinerary;
    	$no_details_found_message = '<p class="wp-travel-no-detail-found-msg">' . __( 'No details found.', 'wp-travel' ) . '</p>';
    	$trip_content             = $wp_travel_itinerary->get_content() ? $wp_travel_itinerary->get_content() : $no_details_found_message;
    	$trip_outline             = $wp_travel_itinerary->get_outline() ? $wp_travel_itinerary->get_outline() : $no_details_found_message;
    	$trip_include             = $wp_travel_itinerary->get_trip_include() ? $wp_travel_itinerary->get_trip_include() : $no_details_found_message;
    	$trip_exclude             = $wp_travel_itinerary->get_trip_exclude() ? $wp_travel_itinerary->get_trip_exclude() : $no_details_found_message;
    	$gallery_ids              = $wp_travel_itinerary->get_gallery_ids();
    
    	$wp_travel_itinerary_tabs = wp_travel_get_frontend_tabs();
    
    	$fixed_departure = get_post_meta( $post_id, 'wp_travel_fixed_departure', true );
    
    	$trip_start_date = get_post_meta( $post_id, 'wp_travel_start_date', true );
    	$trip_end_date   = get_post_meta( $post_id, 'wp_travel_end_date', true );
    	$trip_price      = wp_travel_get_trip_price( $post_id );
    	$enable_sale     = wp_travel_is_enable_sale_price( $post_id );
    
    	$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;
    
    	$settings      = wp_travel_get_settings();
    	$currency_code = ( isset( $settings['currency'] ) ) ? $settings['currency'] : '';
    
    	$currency_symbol = wp_travel_get_currency_symbol( $currency_code );
    	$price_per_text  = wp_travel_get_price_per_text( $post_id );
    	$sale_price      = wp_travel_get_trip_sale_price( $post_id );
    	?>
    	<div id="wp-travel-tab-wrapper" class="wp-travel-tab-wrapper">
    		<?php if ( is_array( $wp_travel_itinerary_tabs ) && count( $wp_travel_itinerary_tabs ) > 0 ) : ?>
    			<ul class="wp-travel tab-list resp-tabs-list ">
    				<?php
    				$index = 1;
    				foreach ( $wp_travel_itinerary_tabs as $tab_key => $tab_info ) :
    					?>
    					<?php if ( 'reviews' === $tab_key && ! comments_open() ) : ?>
    						<?php continue; ?>
    					<?php endif; ?>
    					<?php if ( 'yes' !== $tab_info['show_in_menu'] ) : ?>
    						<?php continue; ?>
    					<?php endif; ?>
    					<?php $tab_label = $tab_info['label']; ?>
    					<li class="wp-travel-ert <?php echo esc_attr( $tab_key ); ?> <?php echo esc_attr( $tab_info['label_class'] ); ?> tab-<?php echo esc_attr( $index ); ?>" data-tab="tab-<?php echo esc_attr( $index ); ?>-cont"><?php echo esc_attr( $tab_label ); ?></li>
    					<?php
    					$index++;
    				endforeach;
    				?>
    			</ul>
    		<div class="resp-tabs-container">
    			<?php if ( is_array( $wp_travel_itinerary_tabs ) && count( $wp_travel_itinerary_tabs ) > 0 ) : ?>
    				<?php $index = 1; ?>
    				<?php foreach ( $wp_travel_itinerary_tabs as $tab_key => $tab_info ) : ?>
    					<?php if ( 'reviews' === $tab_key && ! comments_open() ) : ?>
    						<?php continue; ?>
    					<?php endif; ?>
    					<?php if ( 'yes' !== $tab_info['show_in_menu'] ) : ?>
    						<?php continue; ?>
    					<?php endif; ?>
    					<?php
    					switch ( $tab_key ) {
    
    						case 'reviews':
    							?>
    							<div id="<?php echo esc_attr( $tab_key ); ?>" class="tab-list-content">
    								<?php comments_template(); ?>
    							</div>
    							<?php
    							break;
    						case 'booking':
    							$booking_template = wp_travel_get_template( 'content-pricing-options.php' );
    							load_template( $booking_template );
    
    							break;
    						case 'faq':
    							?>
    						<div id="<?php echo esc_attr( $tab_key ); ?>" class="tab-list-content">
    							<div class="panel-group" id="accordion">
    							<?php
    							$faqs = wp_travel_get_faqs( $post_id );
    							if ( is_array( $faqs ) && count( $faqs ) > 0 ) {
    								?>
    								<div class="wp-collapse-open clearfix">
    									<a href="#" class="open-all-link"><span class="open-all" id="open-all"><?php esc_html_e( 'Open All', 'wp-travel' ); ?></span></a>
    									<a href="#" class="close-all-link" style="display:none;"><span class="close-all" id="close-all"><?php esc_html_e( 'Close All', 'wp-travel' ); ?></span></a>
    								</div>
    								<?php foreach ( $faqs as $k => $faq ) : ?>
    								<div class="panel panel-default">
    								<div class="panel-heading">
    								<h4 class="panel-title">
    									<a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo esc_attr( $k + 1 ); ?>">
    									<?php echo esc_html( $faq['question'] ); ?>
    									<span class="collapse-icon"></span>
    									</a>
    								</h4>
    								</div>
    								<div id="collapse<?php echo esc_attr( $k + 1 ); ?>" class="panel-collapse collapse">
    								<div class="panel-body">
    									<?php echo wp_kses_post( wpautop( $faq['answer'] ) ); ?>
    								</div>
    								</div>
    							</div>
    									<?php
    								endforeach;
    							} else {
    								?>
    								<div class="while-empty">
    									<p class="wp-travel-no-detail-found-msg" >
    										<?php esc_html_e( 'No Details Found', 'wp-travel' ); ?>
    									</p>
    								</div>
    							<?php } ?>
    							</div>
    						</div>
    							<?php
    							break;
    						case 'trip_outline':
    							?>
    						<div id="<?php echo esc_attr( $tab_key ); ?>" class="tab-list-content">
    							<?php
    								echo wp_kses_post( $tab_info['content'] );
    
    								$itinerary_list_template = wp_travel_get_template( 'itineraries-list.php' );
    								load_template( $itinerary_list_template );
    							?>
    						</div>
    							<?php
    							break;
    						default:
    							?>
    							<div id="<?php echo esc_attr( $tab_key ); ?>" class="tab-list-content">
    								<?php
    								if ( apply_filters( 'wp_travel_trip_tabs_output_raw', false, $tab_key ) ) {
    
    									echo do_shortcode( $tab_info['content'] );
    
    								} else {
    
    									echo apply_filters( 'the_content', $tab_info['content'] );
    								}
    
    								?>
    							</div>
    						<?php break; ?>
    					<?php } ?>
    					<?php
    					$index++;
    				endforeach;
    				?>
    			<?php endif; ?>
    		</div>
    		<?php endif; ?>
    
    	</div>
    	<?php
    }

    can anyone please help?

    Thanks

    #21167

    wensolutions
    Keymaster

    Hello,

    Actually, you cannot override template-functions.php as it is not a template. So, if you want to modify the content of template-functions.php file to add your required CSS class then first of all remove the ‘wp_travel_frontend_contents’ action hook of the plugin by adding following code in functions.php file of child theme.

    remove_action( 'wp_travel_single_trip_after_header', 'wp_travel_frontend_contents', 15 );

    Now, copy the content of the function ‘wp_travel_frontend_contents’ and paste it in your custom function then modify the content to add your CSS class and add your custom function in action hook by adding following code in functions.php file of child theme.

    add_action( 'wp_travel_single_trip_after_header', 'wp_travel_frontend_contents_customize', 15 );

    Please replace ‘wp_travel_frontend_contents_customize’ with your custom function.

    Hope this helps.

    Thank you.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.