post_type && has_post_thumbnail()): $thumbnail_id = get_post_thumbnail_id( get_the_ID() ); elseif ( ( (is_single() && 'post' == $post->post_type) || is_home() ) && !apply_filters( 'bahotel_l_option', '', 'blog_header_default' ) && isset(Bahotel_L_Settings::$settings['blog_header_image']['id'])): $thumbnail_id = Bahotel_L_Settings::$settings['blog_header_image']['id']; elseif (is_post_type_archive('event') && !apply_filters( 'bahotel_l_option', '', 'events_header_default' ) && isset(Bahotel_L_Settings::$settings['events_header_image']['id'])): $thumbnail_id = Bahotel_L_Settings::$settings['events_header_image']['id']; elseif (is_post_type_archive('service') && !apply_filters( 'bahotel_l_option', '', 'services_header_default' ) && isset(Bahotel_L_Settings::$settings['services_header_image']['id'])): $thumbnail_id = Bahotel_L_Settings::$settings['services_header_image']['id']; elseif (is_archive() && !apply_filters( 'bahotel_l_option', '', 'archive_header_default' ) && isset(Bahotel_L_Settings::$settings['archive_header_image']['id'])): $thumbnail_id = Bahotel_L_Settings::$settings['archive_header_image']['id']; endif; return absint($thumbnail_id); } endif; /////////////////////////// add_filter( 'bahotel_l_background_spinner', 'bahotel_l_background_spinner', 10, 1 ); if ( ! function_exists( 'bahotel_l_background_spinner' ) ) : /** * Filter background spinner url * * @param string $spinner_url * * @return string */ function bahotel_l_background_spinner($spinner_url) { return Bahotel_L_Settings::$default_spinner; } endif; /////////////////////////// add_filter( 'bahotel_l_background_image_thumbnail', 'bahotel_l_background_image_thumbnail', 10, 1 ); if ( ! function_exists( 'bahotel_l_background_image_thumbnail' ) ) : /** * Filter background image thumbnail * * @param string $thumbnail * * @return string */ function bahotel_l_background_image_thumbnail($thumbnail) { $thumbnail = 'bahotel_gallery_md';//'bahotel_list_vl'; //'bahotel_list_md'; return $thumbnail; } endif; /////////////////////////// add_filter( 'bahotel_l_background_image_thumbnail_md', 'bahotel_l_background_image_thumbnail_md', 10, 1 ); if ( ! function_exists( 'bahotel_l_background_image_thumbnail_md' ) ) : /** * Filter background image thumbnail * * @param string $thumbnail * * @return string */ function bahotel_l_background_image_thumbnail_md($thumbnail) { $thumbnail = 'bahotel_thumbnail_lg'; return $thumbnail; } endif; /////////////////////////// add_filter( 'bahotel_l_background_image_full', 'bahotel_l_background_image_full', 10, 1 ); if ( ! function_exists( 'bahotel_l_background_image_full' ) ) : /** * Filter background image thumbnail * * @param string $thumbnail * * @return string */ function bahotel_l_background_image_full($thumbnail) { $thumbnail = 'bahotel_header'; return $thumbnail; } endif; /////////////////////////// add_filter( 'get_the_archive_title', 'bahotel_l_the_archive_title', 10, 1 ); if ( ! function_exists( 'bahotel_l_the_archive_title' ) ) : /** * Filters the archive title. * * @param string $title Archive title to be displayed. * @return string */ function bahotel_l_the_archive_title($title) { if ( is_post_type_archive() ) { $title = post_type_archive_title( '', false ); } return $title; } endif; //////////////////////////// add_action( 'pre_get_posts', 'bahotel_l_archive_query', 10, 1 ); if ( ! function_exists( 'bahotel_l_archive_query' ) ) : /** * Filters the archive query params * * @param object $query * @return */ function bahotel_l_archive_query($query) { if ( is_post_type_archive( 'service' ) && ! is_admin() && $query->is_main_query() && in_array('service', (array)$query->query_vars['post_type'])) { $query->set( 'posts_per_archive_page', -1 ); $query->set( 'orderby', 'menu_order title' ); $query->set( 'order', 'ASC' ); $services_include_pages = (array) apply_filters( 'bahotel_l_option', array(), 'services_include_pages' ); $services_include_pages = array_map('absint', $services_include_pages); if (array_sum($services_include_pages)){ $post__in = array(); foreach($services_include_pages as $service_page_id => $service_page_include){ if ($service_page_include){ $post__in[] = $service_page_id; } } $query->set( 'post__in', $post__in ); } } if ( is_post_type_archive( 'event' ) && ! is_admin() && $query->is_main_query() && in_array('event', (array)$query->query_vars['post_type'])) { $orderby_first = apply_filters( 'bahotel_l_option', '', 'events_orderby' ); $order = apply_filters( 'bahotel_l_option', 'DESC', 'events_order' ) == 'DESC' ? 'DESC' : 'ASC'; if ('date_event' == $orderby_first){ $query->set( 'meta_key', 'event_date_timestamp' ); $orderby = array( 'meta_value_num' => $order, 'modified' => $order, ); $query->set( 'orderby', $orderby ); } elseif ('modified' == $orderby_first || 'title' == $orderby_first){ $orderby = array( $orderby_first => $order, 'date' => $order, ); $query->set( 'orderby', $orderby ); } } return; } endif; ////////////////////////////////////////////////// add_filter('bahotel_l_block_title_before', 'bahotel_l_block_title_before', 10, 1); if ( ! function_exists( 'bahotel_l_block_title_before' ) ) : ////////////////////////////////////////////////// /** * Filter before block title * * @param string $output * * @return string */ function bahotel_l_block_title_before( $output = '' ) { $output = '
'; return $output; } endif; ////////////////////////////////////////////////// add_filter('bahotel_l_block_title_after', 'bahotel_l_block_title_after', 10, 1); if ( ! function_exists( 'bahotel_l_block_title_after' ) ) : ////////////////////////////////////////////////// /** * Filter after block title * * @param string $output * * @return string */ function bahotel_l_block_title_after( $output = '' ) { $output = '
'; return $output; } endif; ////////////////////////////////////////////////// add_filter('bahotel_l_terms_block', 'bahotel_l_filter_terms_block', 10, 2); if ( ! function_exists( 'bahotel_l_filter_terms_block' ) ) : ////////////////////////////////////////////////// /** * Gets terms html block * * @param string $output * @param array $taxonomies - array of taxonomy slugs * * @return string */ function bahotel_l_filter_terms_block( $output = '', $taxonomies = array() ) { $output = bahotel_l_terms_block( $taxonomies ); return $output; } endif; ////////////////////////////////////////////////// add_filter('bahotel_l_discount_bar_button_title', 'bahotel_l_filter_button_title_add_arrow', 10, 2); add_filter('bahotel_l_offer_item_button_title', 'bahotel_l_filter_button_title_add_arrow', 10, 2); add_filter('bahotel_l_home_carousel_button_title', 'bahotel_l_filter_button_title_add_arrow', 10, 2); if ( ! function_exists( 'bahotel_l_filter_button_title_add_arrow' ) ) : ////////////////////////////////////////////////// /** * Filter button title, add arrow * * @param string $output * @param array $args * * @return string */ function bahotel_l_filter_button_title_add_arrow( $output = '', $args = array() ) { $output .= ' '; return $output; } endif; ////////////////////////////////////////////////// add_filter('bahotel_l_home_carousel_nav_prev', 'bahotel_l_filter_home_carousel_nav_prev', 10, 1); if ( ! function_exists( 'bahotel_l_filter_home_carousel_nav_prev' ) ) : ////////////////////////////////////////////////// /** * Filter carousel prev button * * @param string $output * * @return string */ function bahotel_l_filter_home_carousel_nav_prev( $output = '' ) { $output = ' '; return $output; } endif; ////////////////////////////////////////////////// add_filter('bahotel_l_home_carousel_nav_next', 'bahotel_l_filter_home_carousel_nav_next', 10, 1); if ( ! function_exists( 'bahotel_l_filter_home_carousel_nav_next' ) ) : ////////////////////////////////////////////////// /** * Filter carousel next button * * @param string $output * * @return string */ function bahotel_l_filter_home_carousel_nav_next( $output = '' ) { $output = ' '; return $output; } endif; ////////////////////////////////////////////////// add_filter('bahotel_l_terms_block_classes', 'bahotel_l_filter_block_classes', 10, 2); add_filter('bahotel_l_booking_items_block_classes', 'bahotel_l_filter_block_classes', 10, 2); add_filter('bahotel_l_events_block_classes', 'bahotel_l_filter_block_classes', 10, 2); add_filter('bahotel_l_news_block_classes', 'bahotel_l_filter_block_classes', 10, 2); add_filter('bahotel_l_gallery_block_classes', 'bahotel_l_filter_block_classes', 10, 2); add_filter('bahotel_l_why_choose_us_classes', 'bahotel_l_filter_block_classes', 10, 2); add_filter('bahotel_l_address_contact_form_classes', 'bahotel_l_filter_block_classes', 10, 2); add_filter('bahotel_l_address_block_classes', 'bahotel_l_filter_block_classes', 10, 2); add_filter('bahotel_l_counters_bar_block_classes', 'bahotel_l_filter_block_classes', 10, 2); add_filter('bahotel_l_contact_form_bar_classes', 'bahotel_l_filter_block_classes', 10, 2); if ( ! function_exists( 'bahotel_l_filter_block_classes' ) ) : ////////////////////////////////////////////////// /** * Filter terms block classes * * @param string $output * @param array $args * * @return string */ function bahotel_l_filter_block_classes( $output = '', $args = array() ) { if (Bahotel_L_Settings::$layout_current == 'frontpage' || Bahotel_L_Settings::$layout_current == 'no-sidebars-wide') { $output .= ' container'; } return $output; } endif; //////////////////////////// if ( ! function_exists( 'bahotel_l_terms_block' ) ) : ////////////////////////////////////////////////// /** * Gets terms html block * * @param array $taxonomies - array of taxonomy slugs * * @return string */ function bahotel_l_terms_block( $taxonomies = array() ) { $output = ''; $terms = get_terms( array( 'taxonomy' => $taxonomies, 'hide_empty' => false, ) ); if ( ! empty( $terms ) ) { $results = array(); foreach ( $terms as $term ) { $term_output = ''; $term_meta = get_term_meta($term->term_id); if ( ( isset( $term_meta['image_id'] ) && $term_meta['image_id'][0]) || ( isset( $term_meta['lnr_class'] ) && $term_meta['lnr_class'][0] ) || ( isset( $term_meta['el_class'] ) && $term_meta['el_class'][0] ) || ( isset( $term_meta['fa_class'] ) && $term_meta['fa_class'][0] ) ) { $term_title = '
'.esc_html($term->name).'
'; if ( isset( $term_meta['image_id'] ) && $term_meta['image_id'][0] ) { // Image. $src_arr = wp_get_attachment_image_src( $term_meta['image_id'][0], 'full' ); $term_output = '
'; } elseif ( isset( $term_meta['lnr_class'] ) && $term_meta['lnr_class'][0] ) { // Linear icons. $term_output = '
'; } elseif ( isset( $term_meta['el_class'] ) && $term_meta['el_class'][0] ) { // Elegant Icons. $term_output = '
'; } elseif ( isset( $term_meta['fa_class'] ) && $term_meta['fa_class'][0] ) { // Fontawesome. $term_output = '
'; } $term_output .= $term_title.'
'; } $term_output = apply_filters( 'bahotel_l_terms_block_term_html', $term_output, $term, $taxonomies ); if ( $term_output ) { $results[] = $term_output; } } $output = '
' . wp_kses_post(implode( '', $results )) . '
'; } //// return escaped value return $output; } endif; ////////////////////////////////////////////////// add_filter('bahotel_l_booking_items_block_item', 'bahotel_l_filter_booking_items_block_item', 10, 5); if ( ! function_exists( 'bahotel_l_filter_booking_items_block_item' ) ) : ////////////////////////////////////////////////// /** * Get booking items html block * * @param string $output * @param object $post - WP Post object * @param string $view - col1_s, col1, col2, col3 * @param array $taxonomies - array of taxonomy slugs * @param boolean $with_icons * * @return string */ function bahotel_l_filter_booking_items_block_item( $output = '', $post, $view, $taxonomies, $with_icons ) { $output = bahotel_l_room_view( $post, $view, $taxonomies, $with_icons ); return $output; } endif; ////////////////////////////////////////////////// add_filter('bahotel_l_events_block_item', 'bahotel_l_filter_events_block_item', 10, 2); if ( ! function_exists( 'bahotel_l_filter_events_block_item' ) ) : ////////////////////////////////////////////////// /** * Get event html block * * @param string $output * @param object $post WP Post object * * @return string */ function bahotel_l_filter_events_block_item( $output = '', $post ) { $output = bahotel_l_event_view( $post ); return $output; } endif; ////////////////////// add_filter('bahotel_l_news_block_item', 'bahotel_l_filter_news_block_item', 10, 2); if ( ! function_exists( 'bahotel_l_filter_news_block_item' ) ) : ////////////////////////////////////////////////// /** * Get news html block * * @param string $output * @param object $post WP Post object * * @return string */ function bahotel_l_filter_news_block_item( $output = '', $post ) { $output = bahotel_l_news_view( $post ); return $output; } endif; ///////////////////////////// add_action( 'comment_post', 'bahotel_l_comment_meta_save', 10, 3 ); if ( ! function_exists( 'bahotel_l_comment_meta_save' ) ) : /** * Save comment meta * * @param int $comment_id * @param int|string $comment_approved * @param array $commentdata * @return */ function bahotel_l_comment_meta_save($comment_id, $comment_approved, $commentdata) { if (isset($_POST['from_city']) && $_POST['from_city']){ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $city = sanitize_text_field(wp_unslash($_POST['from_city'])); if ($city){ update_comment_meta( $comment_id, 'from_city', $city ); } } return; } endif; ////////////////////////////// if ( ! function_exists( 'bahotel_l_event_subtitle' ) ) : /** * Get subtitle html * * @param int $post_id * @param string $echo * * @return */ function bahotel_l_event_subtitle( $post_id, $echo = true ) { $output = ''; $tags = array(); $terms = get_the_terms($post_id, 'event_category'); if (!empty($terms) && !is_wp_error($terms)){ $tags[] = apply_filters('translate_text', $terms[0]->name); } $event_date_timestamp = get_post_meta( $post_id, 'event_date_timestamp', 1); if ($event_date_timestamp){ $tags[] = date_i18n( apply_filters( 'bahotel_l_option', '', 'events_post_dateformat' ), $event_date_timestamp ); } $output = '
'.esc_html(implode(' / ', $tags)).'
'; if (!empty($tags) && $echo){ /// already escaped on line 632 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped return; } return $output; } endif; ////////////////////////////// if ( ! function_exists( 'bahotel_l_event_view' ) ) : /** * Get event preview html * * @param object $post WP Post object * * @return string */ function bahotel_l_event_view( $post ) { $output = ''; $thumbnail = apply_filters('bahotel_l_event_view_thumbnail', 'bahotel_list_vl', $post ); $col_class = apply_filters('bahotel_l_event_view_col_class', 'col-sm-12 col-md-6 col-lg-3', $post ); $image_html = wp_get_attachment_image( get_post_thumbnail_id( $post->ID ), $thumbnail ); $image_html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $image_html ); $image_html = '' . $image_html . ''; $output .= '
'.$image_html.'
'.bahotel_l_event_subtitle( $post->ID, false ).'

'.esc_html( get_the_title($post->ID) ).'

'; return $output; } endif; /////////////////////////////////////////////////// add_filter( 'the_content', 'bahotel_l_event_post_content', 10, 1 ); if ( ! function_exists( 'bahotel_l_event_post_content' ) ) : /** * Add content to event post * * @param string $content * @return string */ function bahotel_l_event_post_content($content){ global $post; $output = $content; if (is_single() && in_the_loop() && is_main_query()){ if ( class_exists( 'Bathemeaddon_Shortcodes' ) && $post->post_type == 'event'){ $title = apply_filters( 'bahotel_l_option', '', 'events_related_title' ); $subtitle = apply_filters( 'bahotel_l_option', '', 'events_related_subtitle' ); $orderby = apply_filters( 'bahotel_l_option', '', 'events_related_orderby' ); $order = apply_filters( 'bahotel_l_option', '', 'events_related_order' ); $ids = ''; $ids_arr = (array) get_post_meta($post->ID, 'related_items', 1); if (!empty($ids_arr)){ $ids = implode(',', $ids_arr); } $output .= do_shortcode('[events ids="'.$ids.'" title="'.$title.'" subtitle="'.$subtitle.'" order="'.$order.'" orderby="'.$orderby.'"]'); } } return $output; } endif; ////////////////////////////// if ( ! function_exists( 'bahotel_l_news_view' ) ) : /** * Get news preview html * * @param object $post WP Post object * * @return string */ function bahotel_l_news_view( $post ) { $output = ''; ob_start(); get_template_part( 'template-parts/contents/content', get_post_format() ); $output = ob_get_clean(); $output = '
'.$output.'
'; return $output; } endif; ////////////////////////////// add_action( 'bahotel_l_footer_before', 'bahotel_l_footer_before', 10); if ( ! function_exists( 'bahotel_l_footer_before' ) ) : /** * Add html to the page footer top * * @return */ function bahotel_l_footer_before() { $thumbnail_id = isset(Bahotel_L_Settings::$settings['footer_logo']['id']) ? absint(Bahotel_L_Settings::$settings['footer_logo']['id']) : 0; if ($thumbnail_id){ $img_full_src = wp_get_attachment_image_src( $thumbnail_id, 'full' ); echo ''; } return; } endif; ////////load panels///////// add_action( 'bahotel_l_get_panel', 'bahotel_l_get_panel', 10, 1 ); if ( ! function_exists( 'bahotel_l_get_panel' ) ): /** * Get sidebar for selected widget area * * @param string $sidebar_name * * @return */ function bahotel_l_get_panel( $sidebar_name ) { if (isset(Bahotel_L_Settings::$sidebars[$sidebar_name]) && is_active_sidebar($sidebar_name)){ $sidebar_width = isset(Bahotel_L_Settings::$layout_vars['width'][$sidebar_name]) ? Bahotel_L_Settings::$layout_vars['width'][$sidebar_name] : 12; if ($sidebar_width){ $sidebar_width_class = 'col-lg-'.$sidebar_width; if ($sidebar_name == 'before-header' || $sidebar_name == 'header' || $sidebar_name == 'before-footer' || $sidebar_name == 'footer'){ $sidebar_width_class = ''; } elseif ($sidebar_name == 'footer-left' || $sidebar_name == 'footer-middle-left' || $sidebar_name == 'footer-middle-right' || $sidebar_name == 'footer-right') { $sidebar_width_class = 'col-12 col-sm-6 col-md-4 col-lg-'.$sidebar_width; if (isset(Bahotel_L_Settings::$layout_vars['offset'][$sidebar_name]) && Bahotel_L_Settings::$layout_vars['offset'][$sidebar_name]){ $sidebar_width_class .= ' offset-lg-'.Bahotel_L_Settings::$layout_vars['offset'][$sidebar_name]; } } //// we use 'include' to make variables $sidebar_width_class and $sidebar_name accessable inside template include( locate_template( 'template-parts/sidebar.php', false, false ) ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound } } return; } endif; ////////////////////////////// add_filter( 'bahotel_l_style', 'bahotel_l_style_footer', 10, 2 ); if ( ! function_exists( 'bahotel_l_style_footer' ) ): /** * Patch footer width * * @param string $class * @param string $region * * @return string */ function bahotel_l_style_footer($class, $region) { if ( $region == 'sidebar-footer-left' || $region == 'sidebar-footer-middle-left' || $region == 'sidebar-footer-middle-right' || $region == 'sidebar-footer-right') { $class .= ' col text-center text-lg-left'; } return $class; } endif; ///////Content styling//////// add_filter( 'bahotel_l_style', 'bahotel_l_style_content', 10, 2 ); if ( ! function_exists( 'bahotel_l_style_content' ) ): /** * Get sidebar for selected widget area * * @param string $sidebar_name * @param string $region * * @return string */ function bahotel_l_style_content( $class, $region ) { if ($region == 'content'){ if (Bahotel_L_Settings::$layout_current == 'frontpage' || Bahotel_L_Settings::$layout_current == 'no-sidebars-wide') { $class = 'container-fluid'; } $class .= ' '.Bahotel_L_Settings::$layout_current; } return $class; } endif; //////////////////////////////////// add_filter( 'bahotel_l_column_width', 'bahotel_l_column_width_content', 'content', 10, 2 ); if ( ! function_exists( 'bahotel_l_column_width_content' ) ): /** * Filtering class for wide template * * @param string $sidebar_name * @param string $region * * @return string */ function bahotel_l_column_width_content( $class, $region ) { if ($region == 'content' && (Bahotel_L_Settings::$layout_current == 'frontpage' || Bahotel_L_Settings::$layout_current == 'no-sidebars-wide')){ $class = ''; } return $class; } endif; //////Primary menu items////// add_action('bahotel_l_header_navbar_after', 'bahotel_l_header_navbar_after', 10); if ( ! function_exists( 'bahotel_l_header_navbar_after' ) ): /** * Add items to header after navbar. * * @return */ function bahotel_l_header_navbar_after() { $title = is_user_logged_in() ? ''.esc_html__( 'My account', 'ba-hotel-light' ) : ''.esc_html__( 'Login', 'ba-hotel-light' ); $url = class_exists('BABE_Settings') ? BABE_Settings::get_my_account_page_url() : '#'; /// $title is already escaped echo ''; return; } endif; /////////////////////////////// add_filter( 'wp_nav_menu_items', 'bahotel_l_wp_nav_menu_primary_items', 10, 2 ); if ( ! function_exists( 'bahotel_l_wp_nav_menu_primary_items' ) ): /** * Filters the HTML list content for a specific navigation menu. * * @param string $items The HTML list content for the menu items. * @param stdClass $args An object containing wp_nav_menu() arguments. */ function bahotel_l_wp_nav_menu_primary_items($items, $args) { if ( $args->theme_location == 'primary' ){ $items .= '
'; } return $items; } endif; ////////////////////////////// add_action('wp_head', 'bahotel_l_remove_auto_p', 10); if ( ! function_exists( 'bahotel_l_remove_auto_p' ) ): /** * Remove auto p from front page. * * @return */ function bahotel_l_remove_auto_p() { if ( is_front_page() && is_main_query() ) { remove_filter( 'the_content', 'wpautop' ); } return; } endif; ////////////Breadcrumbs///////// if ( ! function_exists( 'bahotel_l_breadcrumbs' ) ) : /** * Display Yoast SEO breadcrumbs or Breadcrumb NavXT below the header. */ function bahotel_l_breadcrumbs() { if (!is_front_page()){ if ( function_exists( 'bcn_display' ) ) { ?>','
' ); } } return; } endif; ////////////////////////////// add_filter( 'bahotel_l_copyright_text', 'bahotel_l_copyright_text', 10, 1); if ( ! function_exists( 'bahotel_l_copyright_text' ) ) : /** * Get the footer copyright text. * * @param string $content * * @return string */ function bahotel_l_copyright_text($content) { $text = apply_filters( 'bahotel_l_option', '', 'copyrights' ); $text = $text ? $text : __( 'Copyright © {year}, {sitename}', 'ba-hotel-light' ); $text = str_replace( array( '{sitename}', '{year}' ), array( get_bloginfo( 'sitename' ), date_i18n( 'Y' ) ), $text ); return wp_kses_post( $text ); } endif; //////Comments//////////////// if ( ! function_exists( 'bahotel_l_comment_callback' ) ) : /** * Template for comments and pingbacks. * * Used as a callback by wp_list_comments() for displaying the comments. */ function bahotel_l_comment_callback( $comment, $args, $depth ) { // $GLOBALS['comment'] = $comment; if ( class_exists( 'BABE_Post_types' ) ) { $comment_rating_arr = BABE_Rating::get_comment_rating($comment->comment_ID); $comment_rating = !empty($comment_rating_arr) ? BABE_Rating::comment_stars_rendering($comment->comment_ID) : ''; } else { $comment_rating = ''; } if ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) : ?>
  • >
    ', '' ); ?>
  • >
    Edit', 'ba-hotel-light'), '', '' ); ?>
    comment_approved ) : ?>

    'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'], 'before' => '
    ', 'after' => '
    ', ) ) ); ?>
    post_title){ $title = $post->post_title; $title = apply_filters( 'the_title', $title, $post->ID ); $rel = $adjacent == 'previous' ? 'prev' : 'next'; $output = ''; } return $output; } endif; ////////////////////////////////////////////////// /** * BA Book Everything plugin is required. */ if ( class_exists( 'BABE_Post_types' ) ) { ////////////////////////////////////////////////// add_action( 'bahotel_l_entry_header', 'bahotel_l_entry_header', 10 ); if ( ! function_exists( 'bahotel_l_entry_header' ) ) : ////////////////////////////////////////////////// /** * Adds room entry header. * * @param string $post_type * * @return null */ function bahotel_l_entry_header( $post_type ) { global $post; $output = ''; if ( is_single() && class_exists('BABE_Post_types') && BABE_Post_types::$booking_obj_post_type == $post_type ) { $output .= bahotel_l_room_info(); $output = apply_filters( 'bahotel_l_room_entry_header', $output, $post_type); } echo wp_kses($output, Bahotel_L_Settings::$wp_allowedposttags); return; } endif; /////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_room_info' ) ) : ////////////////////////////////////////////////// /** * Creates room info block. * * @return string */ function bahotel_l_room_info() { global $post; $babe_post = BABE_Post_types::get_post($post->ID); $room_info = ''; $slides = BABE_html::block_slider( $babe_post ); $room_info .= '
    ' . wp_kses($slides, Bahotel_L_Settings::$wp_allowedposttags) . '
    '; ///////////title section $room_info .= '

    '.esc_html(get_the_title()).'

    '; ///////////////////////////////// $room_info .= bahotel_l_room_info_tags($post->ID); $room_info .= '
    '; if (apply_filters( 'bahotel_l_option', '', 'room_rating' )){ $room_info .= wp_kses(BABE_Rating::post_stars_rendering($post->ID), Bahotel_L_Settings::$wp_allowedposttags); } $room_info .= '
    '; if (apply_filters( 'bahotel_l_option', '', 'room_booknow_button' )){ $room_info .= ' '; } $room_info = apply_filters( 'bahotel_l_content_room_info', $room_info, $post->ID, $babe_post); $output = '
    ' . $room_info . '
    '; return $output; } endif; /////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_room_info_tags' ) ) : ////////////////////////////////////////////////// /** * Get room tags. * * @param int $post_id - room id * @param string $style - 'full', 'price' * * @return string */ function bahotel_l_room_info_tags($post_id, $style = 'full') { $babe_post = BABE_Post_types::get_post($post_id); $room_info = ''; if ($style == 'full'){ $room_info .= '
    '; ////////////////// $max_guests = absint(get_post_meta( $post_id, 'guests', 1 )); $room_info .= '
    '.apply_filters('bahotel_l_icon', '', 'guests').'
    '; if (isset($babe_post['room_size']) && $babe_post['room_size']){ $last_char = mb_substr($babe_post['room_size'], -1); if ($last_char == 2){ $room_size = mb_substr($babe_post['room_size'], 0, -1).''.$last_char.''; } else { $room_size = $babe_post['room_size']; } $room_info .= '
    '.apply_filters('bahotel_l_icon', '', 'size').'
    '; } } ///////////////// price $room_info .= '
    '; $prices = BABE_Post_types::get_post_price_from($post_id); $price_old = $prices['discount_price_from'] < $prices['price_from'] ? '' . wp_kses_post(BABE_Currency::get_currency_price( $prices['price_from'] )) . '' : ''; $discount = $prices['discount'] ? '
    -' . $prices['discount'] . '%
    ' : ''; $room_info .= $style == 'full' ? '
    '.apply_filters('bahotel_l_icon', '', 'price').' ' . $price_old . ' ' . wp_kses_post(BABE_Currency::get_currency_price( $prices['discount_price_from'] ) ). '
    ' : '
    ' . $price_old . ' ' . wp_kses_post(BABE_Currency::get_currency_price( $prices['discount_price_from'] )) . '' . esc_html__( '/Night', 'ba-hotel-light' ) . '
    '; $room_info .= '
    '; //////////////////// if ($style == 'full'){ $room_info .= '
    '; } return $room_info; } endif; ////////////////////////////////////////////////// add_action( 'cmb2_booking_obj_after_prices', 'bahotel_l_cmb2_booking_obj_after_prices', 10, 3 ); if ( ! function_exists( 'bahotel_l_cmb2_booking_obj_after_prices' ) ) : ////////////////////////////////////////////////// /** * Adds ages comment field. * * @param object $cmb * @param string $prefix * @param object $category * * @return null */ function bahotel_l_cmb2_booking_obj_after_prices( $cmb, $prefix, $category ) { $cmb->add_field( array( 'name' => __( 'Room size', 'ba-hotel-light' ), 'id' => $prefix . 'room_size_' . $category->slug, 'type' => 'text', 'desc' => __( 'with units of measurement', 'ba-hotel-light' ), 'default' => '', 'attributes' => array( 'data-conditional-id' => $prefix . BABE_Post_types::$categories_tax, 'data-conditional-value' => $category->slug, ), ) ); $cmb->add_field( array( 'name' => __( 'Beds', 'ba-hotel-light' ), 'id' => $prefix . 'beds_' . $category->slug, 'type' => 'text', 'desc' => '', 'default' => '', 'attributes' => array( 'data-conditional-id' => $prefix . BABE_Post_types::$categories_tax, 'data-conditional-value' => $category->slug, ), ) ); return; } endif; ////////////////////////////////////////////////// add_filter( 'babe_init_unitegallery_settings', 'bahotel_l_unitegallery_settings' ); if ( ! function_exists( 'bahotel_l_unitegallery_settings' ) ) : ////////////////////////////////////////////////// /** * Filters unitegallery settings. * * @param array $unitegallery_settings * * @return array */ function bahotel_l_unitegallery_settings( $unitegallery_settings ) { $unitegallery_settings['gallery_width'] = '100%'; $unitegallery_settings['gallery_height'] = 620; $unitegallery_settings['gallery_min_width'] = 300; $unitegallery_settings['gallery_min_height'] = 280; $unitegallery_settings['gallery_mousewheel_role'] = 'none'; //$unitegallery_settings['slider_control_zoom'] = false; $unitegallery_settings['thumb_overlay_color'] = '#000000'; $unitegallery_settings['thumb_overlay_opacity'] = 0; $unitegallery_settings['thumb_width'] = 160; $unitegallery_settings['thumb_height'] = 100; $unitegallery_settings['thumb_border_width'] = 1; $unitegallery_settings['thumb_border_color'] = '#ffffff'; $unitegallery_settings['thumb_selected_border_width'] = 5; $unitegallery_settings['thumb_selected_border_color'] = apply_filters( 'bahotel_l_color', '#cccccc', 'color_links' ); $unitegallery_settings['strip_thumbs_align'] = 'center'; $unitegallery_settings['strippanel_padding_top'] = 16; $unitegallery_settings['strip_space_between_thumbs'] = 24; $unitegallery_settings['strippanel_padding_left'] = 40; $unitegallery_settings['strippanel_padding_right'] = 40; $unitegallery_settings['strippanel_padding_bottom'] = 16; $unitegallery_settings['strippanel_background_color'] = apply_filters( 'bahotel_l_color', '#ffffff', 'color_bg_gray' ); $unitegallery_settings['strippanel_enable_buttons'] = false; $unitegallery_settings['strippanel_padding_buttons'] = 20; if (!apply_filters( 'bahotel_l_option', '', 'room_slideshow_thumbnails' )){ $unitegallery_settings['gallery_theme'] = 'slider'; $unitegallery_settings['slider_enable_bullets'] = true; $unitegallery_settings['slider_bullets_space_between'] = 10; $unitegallery_settings['slider_bullets_offset_vert'] = 30; } return $unitegallery_settings; } endif; ////////////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_turnoff_sassy_social_share' ) ) : ////////////////////////////////////////////////// /** * Patch for class-sassy-social-share-public. * * @param obj $post * @param string $content * * @return string */ function bahotel_l_turnoff_sassy_social_share( $post ) { return 1; } endif; /////////////////////////////////////////////////// add_filter( 'the_content', 'bahotel_l_post_content', 100, 1 ); if ( ! function_exists( 'bahotel_l_post_content' ) ) : /** * Add content to booking_obj page. * @param string $content * @return string */ function bahotel_l_post_content($content){ global $post; $output = $content; if (is_single() && in_the_loop() && is_main_query()){ if ($post->post_type == BABE_Post_types::$booking_obj_post_type){ $babe_post = BABE_Post_types::get_post($post->ID); if (!empty($babe_post)){ remove_filter( 'the_content', 'bahotel_l_post_content', 100, 1 ); $output = apply_filters( 'bahotel_l_post_content', $content, $post->ID, $babe_post); } } } return $output; } endif; //// replace BA Book Everything content filter by theme one remove_filter( 'babe_post_content', array( 'BABE_html', 'babe_post_content'), 10, 3 ); add_filter( 'bahotel_l_post_content', 'bahotel_l_room_post_content', 10, 3 ); if ( ! function_exists( 'bahotel_l_room_post_content' ) ) : ////////////////////////////////////////////////// /** * Creates room post content. * * @param string $content * @param int $post_id * @param array $post - BABE post * * @return string */ function bahotel_l_room_post_content( $content, $post_id, $post ) { //// avoid the doubling of the "sharing block" add_filter( 'heateor_sss_disable_sharing', 'bahotel_l_turnoff_sassy_social_share' ); $rules_cat = BABE_Booking_Rules::get_rule_by_obj_id( $post_id ); $output = '

    '.__( 'Description', 'ba-hotel-light' ).'

    '; $output .= '
    ' . wp_kses( $content, Bahotel_L_Settings::$wp_allowedposttags) . '
    '; $taxonomies = apply_filters( 'bahotel_l_option', '', 'taxonomies_on_room_page' ); if ( ! empty( $taxonomies ) && apply_filters( 'bahotel_l_option', '', 'room_features' ) ) { $output .= '

    '.__( 'Room Features', 'ba-hotel-light' ).'

    '; $output .= '
    ' . bahotel_l_room_terms_section( $post_id, $taxonomies, 'icon_text', false ) . '
    '; } //$output .= $content; $block_steps = BABE_html::block_steps( $post ); if ($block_steps){ $step_title = isset( $rules_cat['category_meta']['categories_step_title'] ) && ! empty( $rules_cat['category_meta']['categories_step_title'] ) ? $rules_cat['category_meta']['categories_step_title'] : __( 'Details', 'ba-hotel-light' ); $output .= '

    '. esc_html($step_title) .'

    ' . wp_kses( $block_steps, Bahotel_L_Settings::$wp_allowedposttags) . '
    '; } $block_faq = BABE_html::block_faqs( $post ); if ($block_faq){ $faq_title = isset( $rules_cat['category_meta']['categories_faq_title'] ) && ! empty( $rules_cat['category_meta']['categories_faq_title'] ) ? $rules_cat['category_meta']['categories_faq_title'] : __( 'Questions & Answers', 'ba-hotel-light' ); $output .= '

    '.esc_html($faq_title).'

    ' . wp_kses( $block_faq, Bahotel_L_Settings::$wp_allowedposttags) . '
    '; } $output .= '

    '.__( 'Book this room', 'ba-hotel-light' ).'

    ' . wp_kses( BABE_html::booking_form($post_id), Bahotel_L_Settings::$wp_allowedposttags) . '
    '; //////////////////////////////// if (isset($post['related_items']) && !empty($post['related_items'])){ $related_arr = BABE_Post_types::get_post_related($post); $taxonomies = apply_filters('bahotel_l_option', '', 'search_res_preview_taxonomies'); $output .= '

    '.__( 'You may like', 'ba-hotel-light' ).'

    '; } //// restore previous, remove theme filter remove_filter( 'heateor_sss_disable_sharing', 'bahotel_l_turnoff_sassy_social_share' ); return $output; } endif; ////////////////////////////////////////////////// //////////////////Checkout////////////////// if ( ! function_exists( 'bahotel_l_get_checkout_process_line' ) ) : /** * Get checkout process status line html * * @param int $step * * @return string */ function bahotel_l_get_checkout_process_line($step = 2){ $output = ''; $step = absint($step); if ($step == 0 || $step > 3){ $step = 2; } $message_arr = array( 1 => array( 'class' => 'content-light', 'message' => __('1. Choose Room', 'ba-hotel-light'), ), 2 => array( 'class' => 'content-light', 'message' => __('2. Make a Reservation', 'ba-hotel-light'), ), 3 => array( 'class' => 'content-light', 'message' => __('3. Confirmation', 'ba-hotel-light'), ), ); $message_arr[$step]['class'] = 'checkout_process_line_item_active'; $message_arr = apply_filters( 'bahotel_l_checkout_process_line_items', $message_arr, $step); $output .= '
    '; foreach($message_arr as $message_item){ $output .= ''.esc_html($message_item['message']).''; } $output .= '
    '; return $output; } endif; ////////////////////////////////////////////////// add_filter('babe_chekout_after_order_items', 'bahotel_l_chekout_order_items', 100, 2); if ( ! function_exists( 'bahotel_l_chekout_order_items' ) ) : /** * Filter checkout order items * * @param string $output * @param array $args * * @return string */ function bahotel_l_chekout_order_items($output, $args){ $output = bahotel_l_get_checkout_process_line(2).'

    '.esc_html__('Your reservation', 'ba-hotel-light').'

    '.$output.'
    '; return $output; } endif; /////////////////////////////////////////// add_filter('babe_chekout_form_html', 'bahotel_l_chekout_form_html', 100, 2); if ( ! function_exists( 'bahotel_l_chekout_form_html' ) ) : /** * Filter checkout order items * * @param string $output * @param array $args * * @return string */ function bahotel_l_chekout_form_html($output, $args){ $output = $output.'
    '; return $output; } endif; /////////////////////////////////////////// add_filter('babe_order_items_date_from_html', 'bahotel_l_order_items_date_from_html', 10, 5); if ( ! function_exists( 'bahotel_l_order_items_date_from_html' ) ) : /** * Filter checkout order items * * @param string $date_from_html * @param array $post * @param array $rules_cat * @param obj $date_from_obj * @param array $item * * @return string */ function bahotel_l_order_items_date_from_html($date_from_html, $post, $rules_cat, $date_from_obj, $item){ $date_format = $rules_cat['rules']['basic_booking_period'] == 'day' ? get_option('date_format').' - '.get_option('time_format') : get_option('date_format'); $date_from_html = ' '.( date_i18n( $date_format, strtotime($date_from_obj->format('Y-m-d')) ) ).''; if ($rules_cat['rules']['basic_booking_period'] != 'recurrent_custom'){ $date_to_obj = new DateTime($item['meta']['date_to']); $date_from_html = ''.__( 'Check In:', 'ba-hotel-light' ).''. $date_from_html . ' '.__( 'Check Out:', 'ba-hotel-light' ).' '.( date_i18n( $date_format, strtotime($date_to_obj->format('Y-m-d')) ) ).''; } else { $date_from_html = ''.__( 'Date:', 'ba-hotel-light' ).''. $date_from_html . ''.__( 'Time:', 'ba-hotel-light' ).' '.$date_from_obj->format(get_option('time_format')).''; } $date_from_html = ' '.$date_from_html.' '; return $date_from_html; } endif; //////////////////Confirmation////////////////// add_filter('babe_confirm_content_html', 'bahotel_l_confirm_content_html', 10, 2); if ( ! function_exists( 'bahotel_l_confirm_content_html' ) ) : /** * Confirm page content * * @param string $output * @param array $args * * @return string */ function bahotel_l_confirm_content_html($output, $args){ $order_id = $args['order_id']; $message = ''; if ($args['order_status'] && isset(BABE_Settings::$settings['message_'.$args['order_status']])){ $message .= '
    ' . wp_kses( BABE_Settings::$settings['message_'.$args['order_status']], Bahotel_L_Settings::$wp_allowedposttags) . '
    '; } if ($args['order_status'] == 'payment_expected'){ $message .= ''; } switch ($args['order_status']){ case 'payment_expected': $confirmation_title = esc_html__('Payment is expected', 'ba-hotel-light'); break; case 'payment_processing': $confirmation_title = esc_html__('Payment in progress', 'ba-hotel-light'); break; case 'payment_deferred': case 'payment_received': default: $confirmation_title = esc_html__('Reservation complete', 'ba-hotel-light'); break; } $output = bahotel_l_get_checkout_process_line(3).'

    '.esc_html__('Your reservation', 'ba-hotel-light').'

    ' . wp_kses_post( sprintf( /* translators: %1$s: Order number */ __('Order #%1$s', 'ba-hotel-light'), $args['order_num'] ) . '

    '.BABE_html::order_items($order_id).bahotel_l_order_customer_details($order_id) ).'

    '.$confirmation_title.'

    '. $message .'
    '; return $output; } endif; //////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_order_customer_details' ) ) : /** * Create order customer details html. * @param int $order_id * @return string */ function bahotel_l_order_customer_details($order_id){ $output = ''; $order_meta = BABE_Order::get_order_customer_details($order_id); unset($order_meta['email_check']); $order_meta = apply_filters('babe_order_customer_details_fields', $order_meta, $order_id); $output .= '
    '; foreach($order_meta as $field_name => $field_content){ $output .= '
    '.esc_html(BABE_html::checkout_field_label($field_name)).':
    '.esc_html($field_content).'
    '; } $output .= '
    '; $output = apply_filters('bahotel_l_order_customer_details_html', $output, $order_id); return $output; } endif; ////////////////////////////////////////////////// //////////////////Booking form////////////////// /////////////////////////////////////////////// add_filter('babe_booking_form_date_from_label', 'bahotel_l_booking_form_date_from_label', 10, 1); if ( ! function_exists( 'bahotel_l_booking_form_date_from_label' ) ) : /** * Filter booking form date from label * * @param string $label * @return string */ function bahotel_l_booking_form_date_from_label($label){ $label = esc_html__('Check In:', 'ba-hotel-light'); return $label; } endif; //////////////////////////// add_filter('babe_booking_form_date_to_label', 'bahotel_l_booking_form_date_to_label', 10, 1); if ( ! function_exists( 'bahotel_l_booking_form_date_to_label' ) ) : /** * Filter booking form date from label * * @param string $label * @return string */ function bahotel_l_booking_form_date_to_label($label){ $label = esc_html__('Check Out:', 'ba-hotel-light'); return $label; } endif; ////////////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_button_mobile' ) ) : ////////////////////////////////////////////////// /** * Creates button for mobile screens. * * @param string $title * @param string $url * @param string $classes * * @return string */ function bahotel_l_button_mobile( $title, $url, $classes = '' ) { $output = ''; $output .= ' '; return $output; } endif; ////////////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_room_terms_section' ) ) : ////////////////////////////////////////////////// /** * Gets room terms. * * @param int $post_id * @param array $taxonomies - array of taxonomy slugs * @param string $style - icon_text, icon, text * @param boolean $with_title * @param string $classes * * @return string */ function bahotel_l_room_terms_section( $post_id, $taxonomies = array(), $style = 'icon_text', $with_title = false, $classes = '' ) { $output = ''; $divider = $style == 'text' ? ', ' : ''; $terms = BABE_Post_types::get_post_terms( $post_id ); if ( ! empty( $terms ) ) { foreach ( $terms as $taxonomy_slug => $taxonomy_terms ) { if ( isset( $taxonomy_terms['terms'] ) && ( empty( $taxonomies ) || ( ! empty( $taxonomies ) && isset( $taxonomies[ $taxonomy_slug ] ) && $taxonomies[ $taxonomy_slug ] ) ) ) { $results = array(); $taxonomy_title = $with_title ? ( $style != 'text' ? '

    ' . $taxonomy_terms['name'] . '

    ' : '' ) : ''; foreach( $taxonomy_terms['terms'] as $term ) { $term_output = ''; if ( ( $style == 'icon_text' || $style == 'icon') && ( $term['image_id'] || ( isset( $term['lnr_class'] ) && $term['lnr_class'] ) || ( isset( $term['el_class'] ) && $term['el_class'] ) || ( isset( $term['fa_class'] ) && $term['fa_class'] ) ) ) { $term_title = '
    '.esc_html($term['name']).'
    '; if ( $term['image_id'] ) { // Image. $src_arr = wp_get_attachment_image_src( $term['image_id'], 'full' ); $term_output = '
    '; } elseif ( isset( $term['lnr_class'] ) && $term['lnr_class'] ) { // Linear icons. $term_output = '
    '; } elseif ( isset( $term['el_class'] ) && $term['el_class'] ) { // Elegant icons. $term_output = '
    '; } elseif ( isset( $term['fa_class'] ) && $term['fa_class'] ) { // Fontawesome. $term_output = '
    '; } $term_output .= $term_title.'
    '; } elseif ( $style == 'text' ) { $term_output = $term['name']; } $term_output = apply_filters( 'bahotel_l_room_term_html', $term_output, $term, $style, $taxonomy_slug, $post_id, $taxonomies ); if ( $term_output ) { $results[] = $term_output; } } $result_row = implode( $divider, $results ); $result_row = $style != 'text' ? '
    ' . $result_row . '
    ' : $result_row; $output .= $taxonomy_title . $result_row; } } $output = '
    ' . $output . '
    '; } return $output; } endif; ////////////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_room_term_icons' ) ) : ////////////////////////////////////////////////// /** * Gets room term icons. * * @param int $post_id * @param array $taxonomies - array of taxonomy slugs * @param string $divider * * @return string */ function bahotel_l_room_term_icons( $post_id, $taxonomies = array(), $style = 'icon_text' ) { $output = ''; $divider = $style == 'text' ? ', ' : ''; $terms = BABE_Post_types::get_post_terms( $post_id ); if ( ! empty( $terms ) && ! empty( $taxonomies ) ) { $taxonomies = array_flip($taxonomies); foreach ( $terms as $taxonomy_slug => $taxonomy_terms ) { if ( isset( $taxonomy_terms['terms'] ) && isset( $taxonomies[ $taxonomy_slug ] ) ) { $results = array(); foreach( $taxonomy_terms['terms'] as $term ) { $term_output = ''; if ($style != 'text'){ if ( $term['image_id'] ) { // Image. $src_arr = wp_get_attachment_image_src( $term['image_id'], 'full' ); $term_output = ' '; } elseif ( isset( $term['lnr_class'] ) && $term['lnr_class'] ) { // Linear icons. $term_output = ' '; } elseif ( isset( $term['el_class'] ) && $term['el_class'] ) { // Elegant icons. $term_output = ' '; } elseif ( isset( $term['fa_class'] ) && $term['fa_class'] ) { // Fontawesome. $term_output = ' '; } } $term_output = $term_output ? ''.$term_output.'' : $term_output; $term_output .= $style == 'text' ? esc_html($term['name']) : ( ($style == 'icon_text' && $term_output) ? ''.esc_html($term['name']).'' : '' ); if ($term_output) { $results[] = $term_output; } } if (!empty($results)){ $results_html = $style == 'text' ? implode( $divider, $results ) : '
    ' . implode( $divider.'
    ', $results ). '
    '; $output .= '
    '.$results_html.'
    '; } } } } return $output; } endif; ////////////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_get_term_icon' ) ) : ////////////////////////////////////////////////// /** * Gets term icon. * * @param int $term_id * @param string $taxonomy * * @return string */ function bahotel_l_get_term_icon( $term_id, $taxonomy ) { $output = ''; $image_id = get_term_meta($term_id, 'image_id', 1); $lnr_class = get_term_meta($term_id, 'lnr_class', 1); $el_class = get_term_meta($term_id, 'el_class', 1); $fa_class = get_term_meta($term_id, 'fa_class', 1); if ($image_id) { // Image. $src_arr = wp_get_attachment_image_src( $image_id, 'full' ); $output .= '
    '; } elseif ( $lnr_class ) { // Fontawesome. $output .= '
    '; } elseif ( $el_class ) { // Fontawesome. $output .= '
    '; } elseif ( $fa_class ) { // Fontawesome. $output .= '
    '; } return $output; } endif; ////////////////////////////////////////// add_action( 'bahotel_l_after_header', 'bahotel_l_after_header_search_form', 10 ); if ( ! function_exists( 'bahotel_l_after_header_search_form' ) ) : /** * Add search form html. * * @return string */ function bahotel_l_after_header_search_form(){ global $post; $exclude_pages = apply_filters('bahotel_l_option', array(), 'search_form_exclude_pages'); $exclude_post_types = apply_filters('bahotel_l_option', array(), 'search_form_exclude_post_types'); $show = true; $show = is_page() && isset($exclude_pages[$post->ID]) && $exclude_pages[$post->ID] ? false : $show; $show = isset($post->post_type) && isset($exclude_post_types[$post->post_type]) && $exclude_post_types[$post->post_type] ? false : $show; if ( apply_filters('bahotel_l_show_search_form', $show) ){ if (apply_filters('bahotel_l_option', '', 'search_form_collapsible')){ echo '
    '.esc_html__('Check availability', 'ba-hotel-light').'
    '; } echo wp_kses( bahotel_l_search_form_html(), Bahotel_L_Settings::$wp_allowedposttags); } return; } endif; ////////////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_search_form_html' ) ) : /** * Get search form html. * * @return string */ function bahotel_l_search_form_html(){ $output = ''; if ( class_exists( 'BABE_Search_From' )){ $search_box_class = 'search_form_white_bg'; $search_box_class .= ' search_form_over_header'; $output .= BABE_Search_From::render_form('', array( 'wrapper_class' => $search_box_class, 'form_class' => 'active', )); } return $output; } endif; ////////////////////////////////////////// add_action( 'bahotel_l_content_before', 'bahotel_l_checkout_progress_start', 100 ); if ( ! function_exists( 'bahotel_l_checkout_progress_start' ) ) : /** * Add checkout progress line to search results page * * @return string */ function bahotel_l_checkout_progress_start(){ global $post; if ( is_page() && $post->ID == BABE_Settings::$settings['search_result_page']){ echo '
    '. wp_kses_post( bahotel_l_get_checkout_process_line(1) ) .'
    '; } return; } endif; ////////////////////////////////////////////////// add_filter('babe_search_filter_sort_by_args', 'bahotel_l_search_filter_sort_by_args', 10, 1); if ( ! function_exists( 'bahotel_l_search_filter_sort_by_args' ) ) : ////////////////////////////////////////////////// /** * Filter sort by args array * * @param array $args * * @return array */ function bahotel_l_search_filter_sort_by_args( $args ) { $show_filter = apply_filters('bahotel_l_option', '', 'search_result_sortby'); $show_rating = apply_filters('bahotel_l_option', '', 'search_result_rating'); if (!$show_filter){ $args = array(); } elseif (!$show_rating) { unset($args['rating']); } return $args; } endif; ///////////////////////////////////////////// add_filter('babe_search_result_inner_class', 'bahotel_l_add_row_class', 10, 1); if ( ! function_exists( 'bahotel_l_add_row_class' ) ) : ////////////////////////////////////////////////// /** * Add row class to string * * @param string $class * * @return string */ function bahotel_l_add_row_class( $class = '' ) { return trim($class.' row'); } endif; ///////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_room_meta' ) ) : ////////////////////////////////////////////////// /** * Get room meta html * * @param int $post_id - room post id * * @return string */ function bahotel_l_room_meta( $post_id ) { $output = ''; $babe_post = BABE_Post_types::get_post($post_id); $max_guests = absint(get_post_meta( $post_id, 'guests', 1 )); if (isset($babe_post['room_size']) && $babe_post['room_size']){ $last_char = mb_substr($babe_post['room_size'], -1); if ($last_char == 2){ $room_size = esc_html(mb_substr($babe_post['room_size'], 0, -1)).''.$last_char.''; } else { $room_size = esc_html($babe_post['room_size']); } $output .= '
    '.$room_size.'
    '; } $output .= '
    '.$max_guests.'
    '; if (isset($babe_post['beds']) && $babe_post['beds']){ $output .= '
    '.esc_html($babe_post['beds']).'
    '; } return $output; } endif; ///////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_room_view' ) ) : ////////////////////////////////////////////////// /** * Gets room tile view. * * @param array $post - BABE post * @param string $view - col1_s, col1, col2, col3 * @param array $taxonomies - array of slugs * @param boolean $with_icons * * @return string */ function bahotel_l_room_view( $post, $view, $taxonomies, $with_icons = false ) { $output = ''; switch($view){ case 'col2': default: $thumbnail = 'bahotel_thumbnail_sm'; $col_class = 'list_col2 col-sm-12 col-lg-6'; $icon_style = ''; $info_tags = 'full'; break; } $thumbnail = apply_filters('bahotel_l_room_view_thumbnail', $thumbnail, $post, $view, $taxonomies, $with_icons ); $col_class = apply_filters('bahotel_l_room_view_col_class', $col_class, $post, $view, $taxonomies, $with_icons ); $icon_style = apply_filters('bahotel_l_room_view_icon_style', $icon_style, $post, $view, $taxonomies, $with_icons ); $info_tags = apply_filters('bahotel_l_room_view_info_tags', $info_tags, $post, $view, $taxonomies, $with_icons ); $image_html = wp_get_attachment_image( get_post_thumbnail_id( $post['ID'] ), $thumbnail ); $image_html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $image_html ); $item_url = BABE_Functions::get_page_url_with_args($post['ID'], $_GET); $image = '' . $image_html . ''; $price_old = $post['discount_price_from'] < $post['price_from'] ? '' . BABE_Currency::get_currency_price( $post['price_from'] ) . '' : ''; $discount = $post['discount'] ? '
    -' . $post['discount'] . '%
    ' : ''; $icons = $with_icons && $icon_style && ! empty( $taxonomies ) ? bahotel_l_room_term_icons( $post['ID'], $taxonomies, $icon_style ) : ''; $output .= '
    '.$image.'
    '; $output .= '

    ' . esc_html($post['post_title']) . '

    '; $output .= bahotel_l_room_info_tags($post['ID'], $info_tags).'
    ' . wp_kses( $icons, Bahotel_L_Settings::$wp_allowedposttags) . '
    '; $output .= '
    '; return $output; } endif; ////////////////////////////////////////////////// add_filter( 'babe_search_result_view_full', 'bahotel_l_search_result_view', 10, 3 ); if ( ! function_exists( 'bahotel_l_search_result_view' ) ) : ////////////////////////////////////////////////// /** * Styling search results. * * @param string $content * @param array $post - BABE post * @param string $image * * @return string */ function bahotel_l_search_result_view( $content, $post, $image ) { $output = ''; $view = apply_filters('bahotel_l_option', '', 'search_result_view'); $taxonomies = apply_filters('bahotel_l_option', '', 'search_res_preview_taxonomies'); $output .= bahotel_l_room_view( $post, $view, array_keys($taxonomies), true ); return $output; } endif; ////////////////////////////////////////////////// add_filter( 'body_class', 'bahotel_l_body_custom_class', 10, 1 ); if ( ! function_exists( 'bahotel_l_body_custom_class' ) ) : ////////////////////////////////////////////////// /** * Adds classes to body. * * @param array $classes * * @return array */ function bahotel_l_body_custom_class( $classes ) { $classes[] = Bahotel_L_Settings::$layout_current; if (apply_filters( 'bahotel_l_option', '', 'header_transparent' )){ $classes[] = 'header_transparent'; } if (apply_filters( 'bahotel_l_option', '', 'header_sticky' )){ $classes[] = 'header_sticky'; } return $classes; } endif; //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// //// End if class exist. //////////////////////////////////////////////////////////// } ////////////////////////////////////////////////// /** * Filters the default gallery shortcode output. * * @see gallery_shortcode() * * @param string $output The gallery output. Default empty. * @param array $attr Attributes of the gallery shortcode. * @param int $instance Unique numeric ID of this gallery shortcode instance. */ add_filter( 'post_gallery', 'bahotel_l_post_gallery', 10, 3 ); if ( ! function_exists( 'bahotel_l_post_gallery' ) ) : function bahotel_l_post_gallery($output, $attr, $instance){ $post = get_post(); $atts = shortcode_atts( array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'itemtag' => 'figure', 'icontag' => 'div', 'captiontag' => 'figcaption', 'columns' => 3, 'style' => '', 'size' => 'bahotel_l_gallery_sm', 'include' => '', 'exclude' => '', 'link' => 'file' ), $attr, 'gallery' ); $gallery_style = $atts['style'] ? $atts['style'] : apply_filters( 'bahotel_l_option', '', 'gallery_style' ); $masonry = $gallery_style == 'masonry' ? true : false; $id = intval( $atts['id'] ); if ( ! empty( $atts['include'] ) ) { $_attachments = get_posts( array( 'include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); $attachments = array(); foreach ( $_attachments as $key => $val ) { $attachments[$val->ID] = $_attachments[$key]; } } elseif ( ! empty( $atts['exclude'] ) ) { $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'], 'posts_per_page' => 9 ) ); } else { $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'], 'posts_per_page' => 9 ) ); } if ( empty( $attachments ) ) { return ''; } if ( is_feed() ) { $output = "\n"; foreach ( $attachments as $att_id => $attachment ) { $output .= wp_get_attachment_link( $att_id, $atts['size'], true ) . "\n"; } return $output; } $itemtag = tag_escape( $atts['itemtag'] ); $captiontag = tag_escape( $atts['captiontag'] ); $icontag = tag_escape( $atts['icontag'] ); $valid_tags = wp_kses_allowed_html( 'post' ); if ( ! isset( $valid_tags[ $itemtag ] ) ) { $itemtag = 'figure'; } if ( ! isset( $valid_tags[ $captiontag ] ) ) { $captiontag = 'figcaption'; } if ( ! isset( $valid_tags[ $icontag ] ) ) { $icontag = 'div'; } $columns = intval( $atts['columns'] ); $itemwidth = $columns > 0 ? floor(100/$columns) : 100; $float = is_rtl() ? 'right' : 'left'; $selector = "gallery-{$instance}"; $size_class = sanitize_html_class( $atts['size'] ); $format_class = $atts['size'] != 'thumbnail' ? 'row' : "gallery-columns-{$columns}"; $output = "\n"; return $output; } endif; ////////////////////////////////////////////////// add_filter( 'post_thumbnail_html', 'bahotel_l_remove_thumbnail_width_height', 10, 5 ); if ( ! function_exists( 'bahotel_l_remove_thumbnail_width_height' ) ) : ////////////////////////////////////////////////// /** * Remove width and height attributes from the returning image html * * @return */ function bahotel_l_remove_thumbnail_width_height( $html, $post_id, $post_thumbnail_id, $size, $attr ) { $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html ); return $html; } endif; ////////////////////////////////////////////////// add_action( 'bahotel_l_pagination', 'bahotel_l_pagination', 10 ); if ( ! function_exists( 'bahotel_l_pagination' ) ) : ////////////////////////////////////////////////// /** * Adds pagination. * * @return */ function bahotel_l_pagination() { the_posts_pagination( array( 'prev_text' => '<' . esc_html__( 'Previous page', 'ba-hotel-light' ) . '', 'next_text' => '' . esc_html__( 'Next page', 'ba-hotel-light' ) . '>' , 'before_page_number' => '' . esc_html__( 'Page', 'ba-hotel-light' ) . ' ', ) ); return; } endif; /////////////////////////////////////////////// add_filter( 'excerpt_more', 'bahotel_l_excerpt_read_more', 10, 1 ); if ( ! function_exists( 'bahotel_l_excerpt_read_more' ) ) : ////////////////////////////////////////////////// /** * Filter the "read more" excerpt string link to the post. * * @param string $more "Read more" excerpt string. * * @return string (Maybe) modified "read more" excerpt string. */ function bahotel_l_excerpt_read_more( $more ) { return ''; } endif; ////////////////////////////// add_filter( 'bahotel_l_post_excerpt', 'bahotel_l_filter_post_excerpt', 10, 2 ); if ( ! function_exists( 'bahotel_l_filter_post_excerpt' ) ) : ////////////////////////////////////////////////// /** * Filter the excerpt * * @param string $excerpt excerpt string * @param object $post * * @return string */ function bahotel_l_filter_post_excerpt( $excerpt, $post ) { return bahotel_l_get_excerpt($post->ID, 90); } endif; ///////////////////////////// if ( ! function_exists( 'bahotel_l_get_excerpt' ) ) : /** * Get the post excerpt. * * @param int $post_id * @param int $excerpt_length - words limit * * @return string */ function bahotel_l_get_excerpt($post_id = 0, $excerpt_length = 38){ $output = ''; $post_id = $post_id ? absint($post_id) : get_the_ID(); $post = get_post($post_id); $excerpt_length = absint($excerpt_length); if (!empty($post) && $excerpt_length){ if ( post_password_required( $post ) ) { return __( 'There is no excerpt because this is a protected post.', 'ba-hotel-light' ); } if ( metadata_exists( 'post', $post_id, '_post_excerpt' ) ) : $excerpt = get_post_meta( $post_id, '_post_excerpt', 1 ); else: if ($post->post_excerpt){ $excerpt = $post->post_excerpt; } else { $excerpt = $post->post_content; // get first page content for excerpt $pages = explode('', $excerpt); $excerpt = $pages[0]; // get content until more tag only if ( preg_match( '//', $excerpt, $matches ) ) { $excerpt_arr = explode( $matches[0], $excerpt, 2 ); $excerpt = $excerpt_arr[0]; } // remove shortcodes $excerpt = strip_shortcodes($excerpt); // remove divs with content $excerpt = bahotel_l_strip_tags_content($excerpt, '
    ', true); // remove scripts and styles $excerpt = preg_replace( '@<(script|style)[^>]*?>.*?@si', '', $excerpt ); // remove tags $excerpt = strip_tags($excerpt); // remove urls $excerpt = preg_replace( "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/", '', $excerpt ); $excerpt = str_replace(' ', ' ', $excerpt); // remove line breaks $excerpt = preg_replace( '/[\r\n\t ]+/', ' ', $excerpt ); } // prepare excerpt source to save in DB $words = explode(' ', $excerpt, 150); array_pop($words); $excerpt = implode(' ', $words); //$excerpt = force_balance_tags( $excerpt ); update_post_meta( $post_id, '_post_excerpt', $excerpt ); endif; $words = explode(' ', $excerpt, $excerpt_length + 1); if (count($words) > $excerpt_length){ array_pop($words); } $excerpt = implode(' ', $words); $output = $excerpt ? '

    '.wp_kses_post($excerpt) .'

    ' : ''; } return $output; } endif; /////////////////////////////////////// add_action( 'wp_insert_post', 'bahotel_l_updates_on_insert_post', 10, 3 ); if ( ! function_exists( 'bahotel_l_updates_on_insert_post' ) ) : /** * Clear postmeta '_post_excerpt' when post is updated * * @param int $post_id * @param obj $post WP_Post * @param boolean $update * * @return */ function bahotel_l_updates_on_insert_post( $post_id, $post, $update ) { remove_action( 'wp_insert_post', 'bahotel_l_updates_on_insert_post', 10, 3 ); if ( metadata_exists( 'post', $post_id, '_post_excerpt' ) ){ delete_post_meta($post_id, '_post_excerpt'); } return; } endif; ////////////////////////////////////////// if ( ! function_exists( 'bahotel_l_strip_tags_content' ) ) : /** * Strip tags with content * * @param string $text * @param string $tags * @param boolean $invert * * @return string */ function bahotel_l_strip_tags_content($text, $tags = '', $invert = false) { preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags_arr); $tags_arr = array_unique($tags_arr[1]); if(is_array($tags_arr) AND count($tags_arr) > 0) { if($invert == false) { return preg_replace('@<(?!(?:'. implode('|', $tags_arr) .')\b)(\w+)\b.*?>.*?@si', '', $text); } else { return preg_replace('@<('. implode('|', $tags_arr) .')\b.*?>.*?@si', '', $text); } } elseif($invert == false) { return preg_replace('@<(\w+)\b.*?>.*?@si', '', $text); } return $text; } endif;