Skip to content

Instantly share code, notes, and snippets.

Created February 14, 2018 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9af4582618753c720e6cb2c50f07245b to your computer and use it in GitHub Desktop.
Save anonymous/9af4582618753c720e6cb2c50f07245b to your computer and use it in GitHub Desktop.
add_action('init','wp_travel_customize_single_excerpt');
function wp_travel_customize_single_excerpt( $post_id ) {
if ( ! $post_id ) {
return;
}
//Get Settings
$settings = wp_travel_get_settings();
$enquery_global_setting = isset( $settings['enable_trip_enquiry_option'] ) ? $settings['enable_trip_enquiry_option'] : 'yes';
$global_enquiry_option = get_post_meta( $post_id, 'wp_travel_use_global_trip_enquiry_option', true );
if ( '' === $global_enquiry_option ) {
$global_enquiry_option = 'yes';
}
if( 'yes' == $global_enquiry_option ) {
$enable_enquiry = $enquery_global_setting;
}
else {
$enable_enquiry = get_post_meta( $post_id, 'wp_travel_enable_trip_enquiry_option', true );
}
$wp_travel_itinerary = new WP_Travel_Itinerary();
?>
<div class="trip-short-desc">
<?php the_excerpt(); ?>
</div>
<div class="wp-travel-trip-meta-info">
<ul>
<?php
/**
* @since 1.0.4
*/
do_action( 'wp_travel_single_itinerary_before_trip_meta_list', $post_id );
?>
<li>
<div class="travel-info">
<strong class="title"><?php esc_html_e( 'Trip Type', 'wp-travel' ); ?></strong>
</div>
<div class="travel-info">
<span class="value">
<?php
$trip_types_list = $wp_travel_itinerary->get_trip_types_list();
if ( $trip_types_list ) {
echo wp_kses( $trip_types_list, wp_travel_allowed_html( array( 'a' ) ) );
} else {
echo esc_html( apply_filters( 'wp_travel_default_no_trip_type_text', __( 'No trip type', 'wp-travel' ) ) );
}
?>
</span>
</div>
</li>
<li>
<div class="travel-info">
<strong class="title"><?php esc_html_e( 'Activities', 'wp-travel' ); ?></strong>
</div>
<div class="travel-info">
<span class="value">
<?php
$activity_list = $wp_travel_itinerary->get_activities_list();
if ( $activity_list ) {
echo wp_kses( $activity_list, wp_travel_allowed_html( array( 'a' ) ) );
} else {
echo esc_html( apply_filters( 'wp_travel_default_no_activity_text', __( 'No Activities', 'wp-travel' ) ) );
}
?>
</span>
</div>
</li>
<li>
<div class="travel-info">
<strong class="title"><?php esc_html_e( 'Maximum of ## pax', 'wp-travel' ); ?></strong>
</div>
<div class="travel-info">
<span class="value">
<?php
if ( $group_size = $wp_travel_itinerary->get_group_size() ) {
printf( __( '%d pax', 'wp-travel' ), esc_html( $group_size ) );
} else {
echo esc_html( apply_filters( 'wp_travel_default_group_size_text', __( 'No Size Limit', 'wp-travel' ) ) );
}
?>
</span>
</div>
</li>
<?php if ( comments_open() ) : ?>
<li>
<div class="travel-info">
<strong class="title"><?php esc_html_e( 'Reviews', 'wp-travel' ); ?></strong>
</div>
<div class="travel-info">
<span class="value">
<?php
$count = (int) get_comments_number();
echo '<a href="javascript:void(0)" class="wp-travel-count-info">';
printf( _n( '%s review', '%s reviews', $count, 'wp-travel' ), $count );
echo '</a>'; ?>
</span>
</div>
</li>
<?php endif; ?>
<?php
/**
* @since 1.0.4
*/
do_action( 'wp_travel_single_itinerary_after_trip_meta_list', $post_id );
?>
</ul>
</div>
<div class="booking-form">
<div class="wp-travel-booking-wrapper">
<button class="wp-travel-booknow-btn"><?php esc_html_e( 'Book Now', 'wp-travel' ); ?></button>
<?php if ( 'yes' == $enable_enquiry ) : ?>
<a id="wp-travel-send-enquiries" href="#wp-travel-enquiries">
<span class="wp-travel-booking-enquiry">
<span class="dashicons dashicons-editor-help"></span>
<span>
<?php esc_html_e( 'Trip Enquiry', 'wp-travel'); ?>
</span>
</span>
</a>
<?php endif; ?>
</div>
</div>
<?php
if ( 'yes' == $enable_enquiry ) :
wp_travel_get_enquiries_form();
endif;
?>
<?php
/**
* @since 1.0.4
*/
do_action( 'wp_travel_single_after_booknow', $post_id );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment