diff --git a/viator-collector/includes/class-vc-display.php b/viator-collector/includes/class-vc-display.php index f9804be..cd07386 100644 --- a/viator-collector/includes/class-vc-display.php +++ b/viator-collector/includes/class-vc-display.php @@ -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 ) ) { diff --git a/viator-collector/templates/listing.php b/viator-collector/templates/listing.php index 18f991f..90e4c94 100644 --- a/viator-collector/templates/listing.php +++ b/viator-collector/templates/listing.php @@ -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(); + +
diff --git a/viator-collector/templates/region.php b/viator-collector/templates/region.php new file mode 100644 index 0000000..7ef1e5a --- /dev/null +++ b/viator-collector/templates/region.php @@ -0,0 +1,73 @@ +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(); + ?> +
+
+
+ +

+
+
+ $vc_city ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } + ?> +
+
+
+ +
+ $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' ), + ), + ), + ) + ); + ?> +
+