Add viator-collector plugin (Hop On Hop Off front-end reskin)
Consolidate the plugin into the TourWebsite repository (its separate nested git repo has been removed). Includes the full new-design reskin: scoped design stylesheet, SVG icon sprite, rebuilt listing/single/section templates, and homepage hero/FAQ/testimonials shortcodes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J4hNL1PSHxXbu94SCenpKj
This commit is contained in:
255
viator-collector/templates/single-viator_tour.php
Normal file
255
viator-collector/templates/single-viator_tour.php
Normal file
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
/**
|
||||
* Single Viator tour — "Hop On Hop Off" design (ported from new front/tour.html).
|
||||
* Itinerary and Reviews are not in the mockup; they reuse the design's own
|
||||
* primitives (.notes, .tmeta) so they sit naturally alongside the rest.
|
||||
*/
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
get_header();
|
||||
|
||||
while ( have_posts() ) :
|
||||
the_post();
|
||||
$post_id = get_the_ID();
|
||||
|
||||
$rating = get_post_meta( $post_id, '_vc_rating', true );
|
||||
$reviews = (int) get_post_meta( $post_id, '_vc_review_count', true );
|
||||
$price = get_post_meta( $post_id, '_vc_price_from', true );
|
||||
$currency = get_post_meta( $post_id, '_vc_currency', true );
|
||||
$supplier = get_post_meta( $post_id, '_vc_supplier', true );
|
||||
$duration_min = (int) get_post_meta( $post_id, '_vc_duration_minutes', true );
|
||||
$max_trav = (int) get_post_meta( $post_id, '_vc_max_travelers', true );
|
||||
$freecancel = (int) get_post_meta( $post_id, '_vc_free_cancellation', true );
|
||||
$booking_url = get_post_meta( $post_id, '_vc_booking_url', true );
|
||||
|
||||
$dest_terms = get_the_terms( $post_id, 'viator_destination' );
|
||||
$dest_names = ( $dest_terms && ! is_wp_error( $dest_terms ) ) ? wp_list_pluck( $dest_terms, 'name' ) : array();
|
||||
$cat_terms = get_the_terms( $post_id, 'viator_tag' );
|
||||
$cat_names = ( $cat_terms && ! is_wp_error( $cat_terms ) ) ? array_slice( wp_list_pluck( $cat_terms, 'name' ), 0, 2 ) : array();
|
||||
|
||||
$gallery = vc_json_decode_meta( get_post_meta( $post_id, '_vc_gallery_image_urls', true ), array() );
|
||||
$gallery = array_values( array_filter( (array) $gallery ) );
|
||||
$primary = get_post_meta( $post_id, '_vc_primary_image_url', true );
|
||||
if ( ! $primary && ! empty( $gallery ) ) {
|
||||
$primary = $gallery[0];
|
||||
}
|
||||
$more = array_slice( array_values( array_diff( $gallery, array( $primary ) ) ), 0, 5 );
|
||||
$big_word = ! empty( $dest_names ) ? $dest_names[0] : get_the_title();
|
||||
?>
|
||||
<div class="vc-app vc-single">
|
||||
<section class="hero-tour">
|
||||
<?php if ( $primary ) : ?>
|
||||
<img class="hero-tour__photo" src="<?php echo esc_url( $primary ); ?>" alt="" fetchpriority="high">
|
||||
<?php endif; ?>
|
||||
<div class="hero-tour__sky" aria-hidden="true"></div>
|
||||
<div class="container">
|
||||
<div class="hero-tour__block">
|
||||
<p class="hero-tour__kicker"><?php echo esc_html__( 'Welcome to', 'viator-collector' ); ?></p>
|
||||
<div class="hero-tour__stage">
|
||||
<h1 class="hero-tour__word"><?php echo esc_html( $big_word ); ?></h1>
|
||||
<img class="hero-tour__figure" src="<?php echo esc_url( vc_asset_url( 'img/tower.png' ) ); ?>" alt="" loading="eager">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section tour">
|
||||
<div class="container tour__layout">
|
||||
<div class="tour__main">
|
||||
<header class="tour-head">
|
||||
<h2 class="tour-head__title"><?php the_title(); ?></h2>
|
||||
<div class="tmeta">
|
||||
<?php if ( '' !== (string) $rating ) : ?>
|
||||
<span class="tmeta__item"><?php echo vc_icon( 'star', 'icon--12 tmeta__star' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><b><?php echo esc_html( number_format_i18n( (float) $rating, 1 ) ); ?></b><i>/5</i></span>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! empty( $dest_names ) ) : ?>
|
||||
<span class="tmeta__rule" aria-hidden="true"></span>
|
||||
<span class="tmeta__item"><?php echo vc_icon( 'location', 'tmeta__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><?php echo esc_html( implode( ', ', array_slice( $dest_names, 0, 2 ) ) ); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php if ( $supplier ) : ?>
|
||||
<span class="tmeta__rule" aria-hidden="true"></span>
|
||||
<span class="tmeta__item"><?php echo vc_icon( 'person', 'tmeta__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><?php echo esc_html__( 'from', 'viator-collector' ) . ' ' . esc_html( $supplier ); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<ul class="facts">
|
||||
<?php if ( $duration_min ) : ?>
|
||||
<li class="fact"><?php echo vc_icon( 'duration', 'fact__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><div class="fact__text"><span class="fact__k"><?php echo esc_html__( 'Duration', 'viator-collector' ); ?></span><span class="fact__v"><?php echo esc_html( vc_duration_human( $duration_min ) ); ?></span></div></li>
|
||||
<?php endif; ?>
|
||||
<?php if ( $max_trav ) : ?>
|
||||
<li class="fact"><?php echo vc_icon( 'person', 'fact__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><div class="fact__text"><span class="fact__k"><?php echo esc_html__( 'Max Travelers', 'viator-collector' ); ?></span><span class="fact__v"><?php echo esc_html( sprintf( __( '%d people', 'viator-collector' ), $max_trav ) ); ?></span></div></li>
|
||||
<?php endif; ?>
|
||||
<?php if ( $freecancel ) : ?>
|
||||
<li class="fact"><?php echo vc_icon( 'shield-check', 'fact__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><div class="fact__text"><span class="fact__k"><?php echo esc_html__( 'Free Cancellation', 'viator-collector' ); ?></span><span class="fact__v"><?php echo esc_html__( 'Up to 24 hrs', 'viator-collector' ); ?></span></div></li>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! empty( $cat_names ) ) : ?>
|
||||
<li class="fact"><?php echo vc_icon( 'grid', 'fact__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><div class="fact__text"><span class="fact__k"><?php echo esc_html__( 'Category', 'viator-collector' ); ?></span><span class="fact__v"><?php echo esc_html( implode( ', ', $cat_names ) ); ?></span></div></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
|
||||
<?php if ( get_the_content() ) : ?>
|
||||
<section class="tour__block">
|
||||
<h3 class="tour__ct"><?php echo esc_html__( 'Overview', 'viator-collector' ); ?></h3>
|
||||
<div class="tour__text"><?php the_content(); ?></div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $primary ) : ?>
|
||||
<section class="tour__block">
|
||||
<h3 class="tour__ct"><?php echo esc_html__( 'Gallery', 'viator-collector' ); ?></h3>
|
||||
<div class="gallery">
|
||||
<img class="gallery__hero" src="<?php echo esc_url( $primary ); ?>" alt="<?php echo esc_attr( get_the_title() ); ?>" loading="lazy">
|
||||
<?php foreach ( $more as $url ) : ?>
|
||||
<img src="<?php echo esc_url( $url ); ?>" alt="<?php echo esc_attr( get_the_title() ); ?>" loading="lazy">
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$inc = array_filter( array_map( 'vc_feature_text', (array) vc_json_decode_meta( get_post_meta( $post_id, '_vc_inclusions', true ), array() ) ) );
|
||||
$exc = array_filter( array_map( 'vc_feature_text', (array) vc_json_decode_meta( get_post_meta( $post_id, '_vc_exclusions', true ), array() ) ) );
|
||||
if ( $inc || $exc ) :
|
||||
?>
|
||||
<div class="lists">
|
||||
<?php if ( $inc ) : ?>
|
||||
<section class="ilist">
|
||||
<h3 class="tour__ct"><?php echo esc_html__( "What's included", 'viator-collector' ); ?></h3>
|
||||
<ul class="ilist__items">
|
||||
<?php foreach ( $inc as $row ) : ?>
|
||||
<li><span class="tick tick--yes" aria-hidden="true"><?php echo vc_icon( 'check', 'icon--12' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span><p><?php echo esc_html( $row ); ?></p></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
<?php if ( $exc ) : ?>
|
||||
<section class="ilist">
|
||||
<h3 class="tour__ct"><?php echo esc_html__( "What's Not included", 'viator-collector' ); ?></h3>
|
||||
<ul class="ilist__items">
|
||||
<?php foreach ( $exc as $row ) : ?>
|
||||
<li><span class="tick tick--no" aria-hidden="true"><?php echo vc_icon( 'x', 'icon--12' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span><p><?php echo esc_html( $row ); ?></p></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$steps = vc_itinerary_steps( vc_json_decode_meta( get_post_meta( $post_id, '_vc_itinerary', true ), array() ) );
|
||||
if ( ! empty( $steps ) ) :
|
||||
?>
|
||||
<section class="tour__block">
|
||||
<h3 class="tour__ct"><?php echo esc_html__( 'Itinerary', 'viator-collector' ); ?></h3>
|
||||
<ul class="notes">
|
||||
<?php foreach ( $steps as $step ) : ?>
|
||||
<li class="note"><?php echo vc_icon( 'location', 'note__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><p><?php
|
||||
$name = ! empty( $step['name'] ) ? '<strong>' . esc_html( $step['name'] ) . '</strong> ' : '';
|
||||
echo $name . esc_html( ! empty( $step['description'] ) ? $step['description'] : '' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
?></p></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$info = (array) vc_json_decode_meta( get_post_meta( $post_id, '_vc_additional_info', true ), array() );
|
||||
$info_rows = array_filter( array_map( 'vc_feature_text', $info ) );
|
||||
if ( ! empty( $info_rows ) ) :
|
||||
?>
|
||||
<section class="tour__block">
|
||||
<h3 class="tour__ct"><?php echo esc_html__( 'Good to know', 'viator-collector' ); ?></h3>
|
||||
<ul class="notes">
|
||||
<?php foreach ( $info_rows as $row ) : ?>
|
||||
<li class="note"><?php echo vc_icon( 'info', 'note__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><p><?php echo esc_html( $row ); ?></p></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$policy = vc_json_decode_meta( get_post_meta( $post_id, '_vc_cancellation_policy', true ), array() );
|
||||
$policy_text = is_scalar( $policy ) ? (string) $policy : (string) vc_array_get( $policy, 'description' );
|
||||
$tiers = is_array( $policy ) ? (array) vc_array_get( $policy, 'refundEligibility', array() ) : array();
|
||||
if ( $policy_text || $tiers ) :
|
||||
?>
|
||||
<section class="tour__block">
|
||||
<h3 class="tour__ct"><?php echo esc_html__( 'Cancellation Policy', 'viator-collector' ); ?></h3>
|
||||
<?php if ( $policy_text ) : ?><p class="tour__text"><?php echo esc_html( $policy_text ); ?></p><?php endif; ?>
|
||||
<?php if ( $tiers ) : ?>
|
||||
<div class="policy">
|
||||
<?php
|
||||
foreach ( $tiers as $tier ) :
|
||||
$pct = (int) vc_array_get( $tier, 'percentageRefundable', 0 );
|
||||
$max = vc_array_get( $tier, 'dayRangeMax', null );
|
||||
$min = vc_array_get( $tier, 'dayRangeMin', null );
|
||||
$yes = $pct > 0;
|
||||
$when = ( null !== $max )
|
||||
? sprintf( __( 'Less than %d hours before the start time', 'viator-collector' ), (int) $max * 24 )
|
||||
: sprintf( __( '%d hours or more before the start time', 'viator-collector' ), (int) $min * 24 );
|
||||
?>
|
||||
<div class="statcard statcard--<?php echo $yes ? 'yes' : 'no'; ?>">
|
||||
<?php echo vc_icon( $yes ? 'check' : 'x', 'icon--12 statcard__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<div class="statcard__text">
|
||||
<span class="statcard__k"><?php echo esc_html( sprintf( __( '%d%% Refund', 'viator-collector' ), $pct ) ); ?></span>
|
||||
<span class="statcard__v"><?php echo esc_html( $when ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( '' !== (string) $rating && $reviews ) : ?>
|
||||
<section class="tour__block" id="reviews">
|
||||
<h3 class="tour__ct"><?php echo esc_html__( 'Reviews', 'viator-collector' ); ?></h3>
|
||||
<div class="tmeta">
|
||||
<span class="tmeta__item"><?php echo vc_icon( 'star', 'icon--12 tmeta__star' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><b><?php echo esc_html( number_format_i18n( (float) $rating, 1 ) ); ?></b><i>/5</i></span>
|
||||
<span class="tmeta__rule" aria-hidden="true"></span>
|
||||
<span class="tmeta__item"><?php echo esc_html( sprintf( _n( '%s review', '%s reviews', $reviews, 'viator-collector' ), number_format_i18n( $reviews ) ) ); ?></span>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<aside class="tour__aside">
|
||||
<div class="bookcard">
|
||||
<h2 class="bookcard__title"><?php echo vc_icon( 'info' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?><?php echo esc_html__( 'Tour Details', 'viator-collector' ); ?></h2>
|
||||
|
||||
<div class="bookcard__price">
|
||||
<?php if ( '' !== (string) $price ) : ?>
|
||||
<p class="price">
|
||||
<span class="price__k"><?php echo esc_html__( 'From', 'viator-collector' ); ?></span>
|
||||
<span class="price__v"><?php echo esc_html( vc_money( $price, $currency ) ); ?></span>
|
||||
<span class="price__unit"><?php echo esc_html( ( $currency ? strtoupper( $currency ) . ' ' : '' ) . __( '/ Per person', 'viator-collector' ) ); ?></span>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<a class="btn btn--dark bookcard__cta" href="<?php echo esc_url( $booking_url ? $booking_url : '#' ); ?>"<?php echo $booking_url ? ' target="_blank" rel="nofollow noopener"' : ''; ?>><?php echo esc_html__( 'Check Availability', 'viator-collector' ); ?></a>
|
||||
</div>
|
||||
|
||||
<div class="statcard statcard--teal">
|
||||
<?php echo vc_icon( 'shield-check', 'statcard__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<div class="statcard__text">
|
||||
<span class="statcard__k"><?php echo esc_html__( 'Free Cancellation', 'viator-collector' ); ?></span>
|
||||
<span class="statcard__v"><?php echo esc_html__( 'Up to 24 hrs', 'viator-collector' ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="statcard statcard--yes">
|
||||
<?php echo vc_icon( 'shield-check', 'statcard__icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<div class="statcard__text">
|
||||
<span class="statcard__k"><?php echo esc_html__( 'Reserve now, pay later!', 'viator-collector' ); ?></span>
|
||||
<span class="statcard__v"><?php echo esc_html__( 'Secure your spot today', 'viator-collector' ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</section>
|
||||
</div><!-- #vc-app -->
|
||||
<?php
|
||||
endwhile;
|
||||
|
||||
get_footer();
|
||||
Reference in New Issue
Block a user