- Region page city list uses the design's destination rail (dcard) instead of the unstyled pre-reskin card template - Header menu: structure regions are inserted after the top-level link to the tours archive instead of at the end - Plugin 1.9.2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
100 lines
4.0 KiB
PHP
100 lines
4.0 KiB
PHP
<?php
|
|
/**
|
|
* Region landing page (/{region}/): hero, a grid of the region's cities in
|
|
* Viator Structure order, then every tour in those cities — the main query
|
|
* on a parent term already includes its child terms.
|
|
*/
|
|
defined( 'ABSPATH' ) || exit;
|
|
get_header();
|
|
|
|
$vc_term = get_queried_object();
|
|
$vc_name = ( $vc_term && ! is_wp_error( $vc_term ) ) ? $vc_term->name : __( 'Tours', 'viator-collector' );
|
|
$vc_desc = term_description();
|
|
|
|
// Child city terms, ordered as on the Viator Structure screen.
|
|
$vc_cities = array();
|
|
$vc_order = array_keys( VC_Structure::cities( VC_Structure::get() ) );
|
|
$vc_terms = get_terms(
|
|
array(
|
|
'taxonomy' => 'viator_destination',
|
|
'parent' => $vc_term ? (int) $vc_term->term_id : 0,
|
|
'hide_empty' => false,
|
|
)
|
|
);
|
|
foreach ( is_wp_error( $vc_terms ) ? array() : $vc_terms as $vc_city ) {
|
|
$vc_pos = array_search( (string) get_term_meta( $vc_city->term_id, '_vc_viator_destination_id', true ), array_map( 'strval', $vc_order ), true );
|
|
$vc_cities[ $vc_pos === false ? PHP_INT_MAX - count( $vc_cities ) : $vc_pos ] = $vc_city;
|
|
}
|
|
ksort( $vc_cities );
|
|
|
|
$vc_after_hero = '';
|
|
if ( $vc_cities ) {
|
|
ob_start();
|
|
?>
|
|
<?php // Same destination rail as the homepage's Top Destinations (VC_Sections). ?>
|
|
<section class="section">
|
|
<div class="container">
|
|
<div class="sec-head">
|
|
<?php /* translators: %s: region name. */ ?>
|
|
<h2 class="sec-head__title"><?php echo esc_html( sprintf( __( 'Cities in %s', 'viator-collector' ), $vc_name ) ); ?></h2>
|
|
<div class="sec-head__actions">
|
|
<div class="rail-nav">
|
|
<button class="btn btn--ghost rail-nav__btn" type="button" data-rail-prev="vcRailRegion" aria-label="<?php echo esc_attr__( 'Previous', 'viator-collector' ); ?>"><?php echo vc_icon( 'arrow-left' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></button>
|
|
<button class="btn btn--ghost rail-nav__btn" type="button" data-rail-next="vcRailRegion" aria-label="<?php echo esc_attr__( 'Next', 'viator-collector' ); ?>"><?php echo vc_icon( 'arrow-right' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<ul class="rail rail--dest" id="vcRailRegion">
|
|
<?php
|
|
foreach ( $vc_cities as $vc_city ) :
|
|
$vc_link = get_term_link( $vc_city );
|
|
$vc_image = vc_term_image_url( $vc_city->term_id, 'viator_destination' );
|
|
if ( is_wp_error( $vc_link ) ) {
|
|
continue;
|
|
}
|
|
?>
|
|
<li class="dcard">
|
|
<?php if ( $vc_image ) : ?>
|
|
<img class="dcard__img" src="<?php echo esc_url( $vc_image ); ?>" alt="<?php echo esc_attr( $vc_city->name ); ?>" loading="lazy">
|
|
<?php endif; ?>
|
|
<div class="dcard__body">
|
|
<h3 class="dcard__title"><a href="<?php echo esc_url( $vc_link ); ?>"><?php echo esc_html( $vc_city->name ); ?></a></h3>
|
|
<div class="dcard__meta">
|
|
<div class="meta">
|
|
<span class="meta__k"><?php echo esc_html__( 'Tours', 'viator-collector' ); ?></span>
|
|
<span class="meta__v"><?php echo esc_html( number_format_i18n( (int) $vc_city->count ) ); ?></span>
|
|
</div>
|
|
<?php echo vc_ring_badge( 'VIEW TOURS · VIEW TOURS · ', $vc_link, 'card' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
</section>
|
|
<?php
|
|
$vc_after_hero = ob_get_clean();
|
|
}
|
|
?>
|
|
<main class="vc-app vc-listing vc-listing--term vc-listing--region">
|
|
<?php
|
|
echo vc_get_template( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
'listing.php',
|
|
array(
|
|
'vc_title' => $vc_name,
|
|
/* translators: %s: region name. */
|
|
'vc_subtitle' => $vc_desc ? wp_strip_all_tags( $vc_desc ) : sprintf( __( 'Explore the best tours in %s.', 'viator-collector' ), $vc_name ),
|
|
'vc_after_hero' => $vc_after_hero,
|
|
'vc_crumb' => array(
|
|
array(
|
|
'label' => __( 'Tours', 'viator-collector' ),
|
|
'url' => get_post_type_archive_link( 'viator_tour' ),
|
|
),
|
|
),
|
|
)
|
|
);
|
|
?>
|
|
</main>
|
|
<?php
|
|
get_footer();
|