Skip to content

Instantly share code, notes, and snippets.

@akther80
Created May 16, 2023 11:38
Show Gist options
  • Save akther80/c55ef82d46ef0884e61cda6eca064df3 to your computer and use it in GitHub Desktop.
Save akther80/c55ef82d46ef0884e61cda6eca064df3 to your computer and use it in GitHub Desktop.
MyTravel -Tour v2 tab
if ( ! function_exists( 'mytravel_default_tour_tabs' ) ) {
/**
* Add default tour tabs to hotel pages.
*
* @param array $tabs Array of tabs.
* @return array
*/
function mytravel_default_tour_tabs( $tabs = array() ) {
global $product, $post;
// Description tab - shows product content.
if ( $post->post_content ) {
$tabs['description'] = array(
'title' => esc_html__( 'Description', 'mytravel' ),
'priority' => 10,
'callback' => 'mytravel_single_hotel_description',
);
}
// Itinerary.
$itinerary = mytravel_get_field( 'itinerary_places' );
if ( $itinerary ) {
$tabs['itinerary'] = array(
'title' => esc_html__( 'Itinerary', 'mytravel' ),
'priority' => 20,
'callback' => 'mytravel_single_tour_itinerary',
);
}
// Map.
$map = mytravel_get_field( 'location_map' );
if ( $map ) {
$tabs['map'] = array(
'title' => esc_html__( 'Map', 'mytravel' ),
'priority' => 30,
'callback' => 'mytravel_single_hotel_location_map',
);
}
// FAQ.
$faq = mytravel_get_field( 'faq_tour' );
if ( $faq ) {
$tabs['faq'] = array(
'title' => esc_html__( 'Faq', 'mytravel' ),
'priority' => 40,
'callback' => 'mytravel_single_tour_faq',
);
}
// Reviews tab - shows comments.
if ( comments_open() ) {
$tabs['reviews'] = array(
'title' => esc_html__( 'Reviews', 'mytravel' ),
'priority' => 50,
'callback' => 'comments_template',
);
}
return apply_filters( 'mytravel_default_tour_tabs', $tabs );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment