74 lines
2.4 KiB
PHP
74 lines
2.4 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();
|
|
?>
|
|
<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();
|