feat(display): region landing page with city grid

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 15:23:40 +03:30
parent 8b70ae9104
commit f6153376f9
3 changed files with 83 additions and 1 deletions

View File

@@ -532,6 +532,10 @@ class VC_Display {
}
public static function taxonomy_template( $template ) {
if ( is_tax( 'viator_destination' ) && get_term_meta( get_queried_object_id(), '_vc_region', true ) ) {
$path = get_stylesheet_directory() . '/viator-collector/region.php';
return file_exists( $path ) ? $path : VC_PLUGIN_DIR . 'templates/region.php';
}
if ( is_tax( array( 'viator_destination', 'viator_tag', 'viator_category' ) ) ) {
$path = get_stylesheet_directory() . '/viator-collector/taxonomy-viator.php';
if ( file_exists( $path ) ) {

View File

@@ -6,10 +6,13 @@
* Filtering stays server-side: every control lives inside #vc-filter-form and
* submits via GET. VC_Display::filter_archive_query() reads the same state.
*
* Args: $vc_title, $vc_subtitle, $vc_query, $vc_form_action.
* Args: $vc_title, $vc_subtitle, $vc_query, $vc_form_action, $vc_after_hero
* (HTML printed between the hero and the results, e.g. the region city grid).
*/
defined( 'ABSPATH' ) || exit;
$vc_after_hero = isset( $vc_after_hero ) ? (string) $vc_after_hero : '';
$f = VC_Display::get_filter_state();
$vc_title = isset( $vc_title ) ? $vc_title : __( 'Explore Tours', 'viator-collector' );
@@ -179,6 +182,8 @@ $vc_hero_img = vc_hero_image_source();
<?php echo vc_ring_badge( 'SCROLL DOWN · SCROLL DOWN · ', '#tour-list', 'scroll' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</section>
<?php echo $vc_after_hero; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built by the calling template. ?>
<section class="section" id="tour-list">
<div class="container">
<div class="results">

View File

@@ -0,0 +1,73 @@
<?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();
?>
<section class="vc-section vc-section--destinations">
<div class="vc-container">
<header class="vc-section__head vc-reveal">
<?php /* translators: %s: region name. */ ?>
<h2 class="vc-section__title"><?php echo esc_html( sprintf( __( 'Cities in %s', 'viator-collector' ), $vc_name ) ); ?></h2>
</header>
<div class="vc-destination-grid">
<?php
foreach ( $vc_cities as $vc_city ) {
echo vc_get_template( 'card-destination.php', array( 'term' => $vc_city ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</div>
</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();