Skip to content

Instantly share code, notes, and snippets.

@akther80
Created June 6, 2023 04:59
Show Gist options
  • Save akther80/ff78c660eb723b32f4ed78573d636c10 to your computer and use it in GitHub Desktop.
Save akther80/ff78c660eb723b32f4ed78573d636c10 to your computer and use it in GitHub Desktop.
MyTravel - Add image in tour itinerary
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="single-hotel__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 ?>
<?php if ( ! empty( $itinerary['image'] ) ) : ?>
<p class="mb-0 mt-3">
<?php echo wp_get_attachment_image( $itinerary['image']['id'], 'full', false, [ 'class' => 'img-fluid rounded-sm' ] ); ?>
</p>
<?php endif ?>
</div>
</div>
</div>
<!-- End Card -->
<?php
$index++;
endforeach;
?>
</div>
</div>
<?php
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment