Skip to content

Instantly share code, notes, and snippets.

@akther80
Last active April 5, 2023 10:43
Show Gist options
  • Save akther80/f5befb1aa39e0d693ba02238242fab8b to your computer and use it in GitHub Desktop.
Save akther80/f5befb1aa39e0d693ba02238242fab8b to your computer and use it in GitHub Desktop.
MyTravel - Iternary style
if ( ! function_exists( 'mytravel_tour_tabs' ) ) {
/**
* Output of tour tabs
*/
function mytravel_tour_tabs() {
$tour_tabs = apply_filters( 'mytravel_tour_tabs', array() );
?>
<div id="stickyBlockStartPointTabs" class="mb-4">
<div class="border rounded-pill rounded js-sticky-block p-1 border-width-2 z-index-4 bg-white"
data-parent="#stickyBlockStartPointTabs"
data-offset-target="#header"
data-sticky-view="lg"
data-start-point="#stickyBlockStartPointTabs"
data-end-point="#stickyBlockEndPointReviews"
data-offset-top="0"
data-offset-bottom="30">
<ul class="js-scroll-nav nav tab-nav-pill flex-nowrap tab-nav">
<?php
foreach ( $tour_tabs as $key => $tab ) :
?>
<li class="text-nowrap nav-item">
<a class="nav-link font-weight-medium" href="#<?php echo esc_attr( $key ); ?>">
<div class="d-flex flex-column flex-md-row position-relative text-dark align-items-center">
<span class="tabtext font-weight-semi-bold"><?php echo esc_html( $tab['title'] ); ?></span>
</div>
</a>
</li>
<?php
endforeach;
?>
</ul>
</div>
</div>
<?php
}
}
if ( ! function_exists( 'mytravel_single_tour_itinerary' ) ) {
/**
* Output of single tour itinerary
*/
function mytravel_single_tour_itinerary() {
if ( ! mytravel_is_acf_activated() ) {
return;
}
$tour_itinerary = mytravel_get_field( 'itinerary_places' );
$should_display = false;
if ( is_array( $tour_itinerary ) ) {
foreach ( $tour_itinerary as $key => $itinerary ) {
if ( ! empty( $itinerary ) ) {
$should_display = true;
break;
}
}
}
if ( $tour_itinerary && $should_display ) {
?>
<div id="itinerary" class="border-bottom py-4">
<h5 class="font-size-21 font-weight-bold text-dark mb-4">
<?php
esc_html_e( 'Itinerary', 'mytravel' );
?>
</h5>
<div id="basicsAccordion1">
<?php
$index = 0;
foreach ( $tour_itinerary as $key => $itinerary ) :
if ( empty( $itinerary ) ) {
continue;
}
// $field = get_field_object( 'itinerary_' . $key );
$tab_count = $index + 1;
?>
<!-- Card -->
<div class="card border-0 mb-3">
<div class="card-header border-bottom-0 p-0" id="heading-<?php echo esc_attr( $tab_count ); ?>">
<h5 class="mb-0">
<?php if ( ! empty( $itinerary['label'] ) || ! empty( $itinerary['title'] ) ) : ?>
<a role="button" href="#" class="collapse-link btn btn-link btn-block d-flex align-items-md-center font-weight-bold p-0" data-toggle="collapse" data-target="#collapse-<?php echo esc_attr( $tab_count ); ?>" aria-expanded="<?php echo esc_attr( 0 === $index ) ? 'true' : 'false'; ?>" aria-controls="collapse-<?php echo esc_attr( $tab_count ); ?>">
<span class="d-inline-block text-primary font-size-22 mb-3 mb-md-0 mr-3">
<i class="far fa-circle"></i>
</span>
<?php if ( ! empty( $itinerary['label'] ) ) : ?>
<span class="d-inline-block text-primary flex-shrink-0">
<?php
echo esc_html( $itinerary['label'] );
?>
<span class="px-2">-</span>
</span>
<?php endif ?>
<?php if ( ! empty( $itinerary['title'] ) ) : ?>
<span class="d-inline-block h6 font-weight-bold text-gray-3 text-left mb-0"><?php echo esc_html( $itinerary['title'] ); ?></span>
<?php endif ?>
</a>
<?php endif ?>
</h5>
</div>
<div id="collapse-<?php echo esc_attr( $tab_count ); ?>" class="collapse
<?php
if ( 1 === $tab_count ) :
?>
show<?php endif; ?>" aria-labelledby="heading-<?php echo esc_attr( $tab_count ); ?>" data-parent="#basicsAccordion1">
<div class="card-body pl-6 pb-0 pt-0">
<?php if ( ! empty( $itinerary['description'] ) ) : ?>
<p class="mb-0">
<?php echo esc_html( $itinerary['description'] ); ?>
</p>
<?php endif ?>
</div>
</div>
</div>
<!-- End Card -->
<?php
$index++;
endforeach;
?>
</div>
</div>
<?php
}
}
}
if ( ! function_exists( 'mytravel_single_tour_faq' ) ) {
/**
* Ouput of single tour FAQ
*/
function mytravel_single_tour_faq() {
if ( ! mytravel_is_acf_activated() ) {
return;
}
$group = mytravel_get_field( 'faq_tour' );
$should_display = false;
if ( is_array( $group ) ) {
foreach ( $group as $key => $faq ) {
if ( ! empty( $faq ) ) {
$should_display = true;
break;
}
}
}
if ( is_array( $group ) && $should_display ) {
?>
<div id="faq" class="border-bottom py-4">
<h5 class="font-size-21 font-weight-bold text-dark mb-4">
<?php
esc_html_e( 'Faq', 'mytravel' );
?>
</h5>
<div id="faqAccordion1">
<?php
$index = 0;
foreach ( $group as $key => $faq ) :
if ( empty( $faq ) ) {
continue;
}
// $field = get_field_object( 'faq_' . $key );
$tab_count = $index + 1;
?>
<!-- Card -->
<?php if ( ! empty( $faq['title'] ) || ! empty( $faq['description'] ) ) : ?>
<div class="card border-0 mb-3">
<div class="card-header border-bottom-0 p-0" id="faq-heading-<?php echo esc_attr( $tab_count ); ?>">
<h5 class="mb-0">
<a role="button" class="collapse-link btn btn-link btn-block d-flex align-items-md-center p-0" href="#" data-toggle="collapse" data-target="#faq-collapse-<?php echo esc_attr( $tab_count ); ?>" aria-expanded="<?php echo esc_attr( 0 === $index ) ? 'true' : 'false'; ?>" aria-controls="faq-collapse-<?php echo esc_attr( $tab_count ); ?>">
<span class="d-inline-block border border-color-8 rounded-xs border-width-2 p-2 mb-3 mb-md-0 mr-4">
<span class="minus" style="">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16px" height="2px" class="injected-svg js-svg-injector mb-0" data-parent="#rectangle"><path fill-rule="evenodd" fill="rgb(59, 68, 79)" d="M-0.000,-0.000 L15.000,-0.000 L15.000,2.000 L-0.000,2.000 L-0.000,-0.000 Z"></path></svg>
</span>
<span class="plus" style="">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16px" height="16px" class="injected-svg js-svg-injector mb-0" data-parent="#plus1"><path fill-rule="evenodd" fill="rgb(59, 68, 79)" d="M16.000,9.000 L9.000,9.000 L9.000,16.000 L7.000,16.000 L7.000,9.000 L-0.000,9.000 L-0.000,7.000 L7.000,7.000 L7.000,-0.000 L9.000,-0.000 L9.000,7.000 L16.000,7.000 L16.000,9.000 Z"></path></svg>
</span>
</span>
<?php if ( ! empty( $faq['title'] ) ) : ?>
<span class="h6 font-weight-bold text-gray-3 mb-0"><?php echo esc_html( $faq['title'] ); ?></span>
<?php endif; ?>
</a>
</h5>
</div>
<div id="faq-collapse-<?php echo esc_attr( $tab_count ); ?>" class="collapse
<?php
if ( 1 === $tab_count ) :
?>
show<?php endif; ?>" aria-labelledby="faq-heading-<?php echo esc_attr( $tab_count ); ?>" data-parent="#faqAccordion1">
<div class="card-body pl-10 pl-md-10 pr-md-12 pt-0">
<?php if ( ! empty( $faq['description'] ) ) : ?>
<p class="mb-0 text-gray-1 text-lh-lg">
<?php echo esc_html( $faq['description'] ); ?>
</p>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<!-- End Card -->
<?php
$index++;
endforeach;
?>
</div>
</div>
<?php
}
}
}
if ( ! function_exists( 'mytravel_single_hotel_location_map' ) ) {
/**
* Output single hotel location map
*/
function mytravel_single_hotel_location_map() {
if ( ! mytravel_is_acf_activated() ) {
return;
}
$location = mytravel_get_field( 'location_map' );
if ( $location ) :
?>
<div id="map" class="position-relative border-bottom pt-4 pb-5">
<h5 class="font-size-21 font-weight-bold text-dark mb-4"><?php echo esc_html__( 'Location', 'mytravel' ); ?></h5>
<div class="acf-map" data-zoom="14" style="width: 100%; height: 480px;">
<div class="marker" data-lat="<?php echo esc_attr( $location['lat'] ); ?>" data-lng="<?php echo esc_attr( $location['lng'] ); ?>"></div>
</div>
</div>
<?php
endif;
}
}
if ( ! function_exists( 'mytravel_single_hotel_description' ) ) {
/**
* Output single hotel description
*/
function mytravel_single_hotel_description() {
$product_format = mytravel_get_product_format();
$title_class = '';
if ( 'hotel' !== $product_format ) {
$title_class = ' mb-3';
}
?>
<div id="description" class="border-bottom position-relative">
<h5 id="scroll-description" class="font-size-21 font-weight-bold text-dark
<?php echo esc_attr( $title_class ); ?>">
<?php
echo esc_html__( 'Description', 'mytravel' );
?>
</h5>
<div class="description">
<?php
the_content();
?>
</div>
</div>
<?php
}
}
if ( ! function_exists( 'mytravel_tour_title' ) ) {
/**
* Output tour title
*/
function mytravel_tour_title() {
?>
<div class="mb-2 mb-md-0">
<?php
the_title( '<h1 class="font-size-23 font-weight-bold mb-1 mr-3">', '</h1>' );
?>
</div>
<?php
}
}
#basicsAccordion1 .collapse-link[aria-expanded=false]:after {
content:"+";
position:absolute;
display: inline-block;
right:0;
}
#basicsAccordion1 .collapse-link[aria-expanded=true]:after {
content:"-";
position:absolute;
display: inline-block;
right:0;
}
#basicsAccordion1 .collapse-link > span:first-child {
display: none !important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment