Add viator-collector plugin (Hop On Hop Off front-end reskin)

Consolidate the plugin into the TourWebsite repository (its separate
nested git repo has been removed). Includes the full new-design reskin:
scoped design stylesheet, SVG icon sprite, rebuilt listing/single/section
templates, and homepage hero/FAQ/testimonials shortcodes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4hNL1PSHxXbu94SCenpKj
This commit is contained in:
2026-09-12 21:11:20 +03:30
parent 99e5413fee
commit 7ada8860f8
42 changed files with 9019 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
<?php
defined( 'ABSPATH' ) || exit;
class VC_CPT {
public static function init() {
add_action( 'init', array( __CLASS__, 'register' ) );
// "Featured" flag: sorts a tour first in search/filter results.
add_action( 'add_meta_boxes', array( __CLASS__, 'add_featured_box' ) );
add_action( 'save_post_viator_tour', array( __CLASS__, 'save_featured' ) );
add_filter( 'manage_viator_tour_posts_columns', array( __CLASS__, 'featured_column' ) );
add_action( 'manage_viator_tour_posts_custom_column', array( __CLASS__, 'featured_column_value' ), 10, 2 );
}
public static function register() {
register_post_type(
'viator_tour',
array(
'labels' => array(
'name' => __( 'Viator Tours', 'viator-collector' ),
'singular_name' => __( 'Viator Tour', 'viator-collector' ),
'add_new_item' => __( 'Add New Viator Tour', 'viator-collector' ),
'edit_item' => __( 'Edit Viator Tour', 'viator-collector' ),
),
'public' => true,
'has_archive' => true,
'rewrite' => array( 'slug' => 'tours' ),
'show_in_rest' => true,
'menu_icon' => 'dashicons-location-alt',
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'custom-fields' ),
)
);
}
public static function add_featured_box() {
add_meta_box(
'vc_featured',
__( 'Featured', 'viator-collector' ),
array( __CLASS__, 'render_featured_box' ),
'viator_tour',
'side',
'high'
);
}
public static function render_featured_box( $post ) {
wp_nonce_field( 'vc_featured', 'vc_featured_nonce' );
$on = (int) get_post_meta( $post->ID, '_vc_featured', true );
?>
<label>
<input type="checkbox" name="vc_featured" value="1" <?php checked( $on, 1 ); ?>>
<?php echo esc_html__( 'Show this tour first in search & filter results.', 'viator-collector' ); ?>
</label>
<?php
}
public static function save_featured( $post_id ) {
if ( ! isset( $_POST['vc_featured_nonce'] ) || ! wp_verify_nonce( sanitize_key( $_POST['vc_featured_nonce'] ), 'vc_featured' ) ) {
return;
}
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
if ( ! empty( $_POST['vc_featured'] ) ) {
update_post_meta( $post_id, '_vc_featured', '1' );
} else {
delete_post_meta( $post_id, '_vc_featured' );
}
}
public static function featured_column( $cols ) {
$cols['vc_featured'] = __( 'Featured', 'viator-collector' );
return $cols;
}
public static function featured_column_value( $col, $post_id ) {
if ( 'vc_featured' === $col && get_post_meta( $post_id, '_vc_featured', true ) ) {
echo '<span class="dashicons dashicons-star-filled" style="color:#f5a623" title="' . esc_attr__( 'Featured', 'viator-collector' ) . '"></span>';
}
}
}