File: /home/zwafgyp/dodolodge-net/wp-content/themes/hotel-wp/inc/widgets/hb-rooms/tpl/default.php
<?php
/**
* Template for displaying default element.
*
*
* @author ThimPress
* @package Thim_Builder/Templates
* @version 1.0.0
* @author Thimpress, tuanta
*/
$css_animation = thim_getCSSAnimation( $instance['css_animation'] );
$number_rooms = 3;
if ( $instance['number_rooms'] ) {
$number_rooms = $instance['number_rooms'];
}
$args = array(
'post_type' => 'hb_room',
'posts_per_page' => $number_rooms,
'orderby' => 'date',
'order' => 'DESC',
);
/* remove action */
remove_action( 'pre_get_posts', 'hotel_booking_num_room_archive', 999 );
$query = new WP_Query( $args );
$thim_options = get_theme_mods();
$style_room = isset( $thim_options['room_style'] ) ? $thim_options['room_style'] : 'style-1';
$rooms_layout = $owl_class = '';
$rooms_layout = $instance['rooms_layout'];
if($rooms_layout == 'slider' && $style_room =='style-1'){
$owl_class .= ' ' . 'owl-carousel';
}
$html = '<div class="thim-sc-hb-rooms row ' . esc_attr($rooms_layout) .' '. esc_attr( $style_room ) . ' ' . $css_animation . '">';
if ( $query->have_posts() ):
if ( $instance['link_text'] == '' ) {
$html .= '<div class="link-to-rooms col-sm-12">';
$html .= '</div>';
} else {
$html .= '<div class="link-to-rooms col-sm-12">';
$html .= '<a class="btn-link" href="' . esc_url( get_post_type_archive_link( 'hb_room' ) ) . '"><i class="icomoon icon-up"></i>' . esc_attr( $instance['link_text'] ) . '</a>';
$html .= '</div>';
}
$html .= '<div class="row rooms tp-hotel-booking hb-catalog-column-' . esc_attr( $number_rooms ) . ' ' . esc_attr( $style_room ) . ' '. esc_attr($owl_class) .'">';
ob_start();
while ( $query->have_posts() ) : $query->the_post();
if($rooms_layout == 'slider'){
hb_get_template_part( 'content', 'room-related' );
}else{
hb_get_template_part( 'content', 'room' );
}
endwhile;
$html .= ob_get_clean();
$html .= '</div>';
if($rooms_layout == 'slider' && $style_room !='style-1'){
$html .='<div class="slider__counter"><div class="slider-nav"><span class="current-item"></span><span class="total-items"></span></div></div>';
}else{
$html .='';
}
else:
esc_html_e( 'No room found', 'hotel-wp' );
endif;
$html .= '</div>';
wp_reset_postdata();
/* add action again */
add_action( 'pre_get_posts', 'hotel_booking_num_room_archive', 999 );
echo $html;