fix: styled city cards on region pages; regions follow All Tours in the menu

- 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>
This commit is contained in:
2026-10-29 16:27:31 +03:30
parent f58ed49d07
commit d0c48e0e8e
4 changed files with 60 additions and 17 deletions

Binary file not shown.

View File

@@ -17,12 +17,29 @@ class VC_Menu {
if ( empty( $args->theme_location ) || self::LOCATION !== $args->theme_location ) {
return $items;
}
$order = count( $items );
$extra = self::items();
foreach ( $extra as $item ) {
$item->menu_order = ++$order;
if ( ! $extra ) {
return $items;
}
return array_merge( $items, $extra );
// Regions go right after the top-level link to the tours archive ("All
// Tours"); without one, at the end. The walker renders top-level items
// in array order.
$items = array_values( $items );
$position = count( $items );
$archive = untrailingslashit( (string) get_post_type_archive_link( 'viator_tour' ) );
foreach ( $items as $i => $item ) {
if ( empty( $item->menu_item_parent ) && '' !== $archive && untrailingslashit( (string) $item->url ) === $archive ) {
$position = $i + 1;
break;
}
}
array_splice( $items, $position, 0, $extra );
foreach ( $items as $i => $item ) {
$item->menu_order = $i + 1;
}
return $items;
}
/**

View File

@@ -31,19 +31,45 @@ $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 // 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="vc-section__title"><?php echo esc_html( sprintf( __( 'Cities in %s', 'viator-collector' ), $vc_name ) ); ?></h2>
</header>
<div class="vc-destination-grid">
<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 ) {
echo vc_get_template( 'card-destination.php', array( 'term' => $vc_city ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
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

View File

@@ -4,13 +4,13 @@ defined('ABSPATH') || exit;
/**
* Plugin Name: Viator Collector
* Description: Import Viator tours using the Viator Partner API and display them with native WordPress post types, templates, and shortcodes.
* Version: 1.9.1
* Version: 1.9.2
* Author: Amir Bagheri
* License: GPL-2.0-or-later
* Text Domain: viator-collector
*/
define('VC_VERSION', '1.9.1');
define('VC_VERSION', '1.9.2');
define('VC_PLUGIN_FILE', __FILE__);
define('VC_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('VC_PLUGIN_URL', plugin_dir_url(__FILE__));