array( 'label' => array( 'mphb_render_single_room_type_before_adults' => '_renderAdultsTitle', ), 'default' => array( 'mphb_render_single_room_type_before_adults' => '_renderAdultsListItemOpen', 'mphb_render_single_room_type_after_adults' => '_renderAdultsListItemClose', ), ), 'children' => array( 'label' => array( 'mphb_render_single_room_type_before_children' => '_renderChildrenTitle', ), 'default' => array( 'mphb_render_single_room_type_before_children' => '_renderChildrenListItemOpen', 'mphb_render_single_room_type_after_children' => '_renderChildrenListItemClose', ), ), 'capacity' => array( 'label' => array( 'mphb_render_single_room_type_before_total_capacity' => '_renderTotalCapacityTitle', ), 'default' => array( 'mphb_render_single_room_type_before_total_capacity' => '_renderTotalCapacityListItemOpen', 'mphb_render_single_room_type_after_total_capacity' => '_renderTotalCapacityListItemClose', ), ), 'amenities' => array( 'label' => array( 'mphb_render_single_room_type_before_facilities' => '_renderFacilitiesTitle', ), 'default' => array( 'mphb_render_single_room_type_before_facilities' => '_renderFacilitiesListItemOpen', 'mphb_render_single_room_type_after_facilities' => '_renderFacilitiesListItemClose', ), ), 'view' => array( 'label' => array( 'mphb_render_single_room_type_before_view' => '_renderViewTitle', ), 'default' => array( 'mphb_render_single_room_type_before_view' => '_renderViewListItemOpen', 'mphb_render_single_room_type_after_view' => '_renderViewListItemClose', ), ), 'size' => array( 'label' => array( 'mphb_render_single_room_type_before_size' => '_renderSizeTitle', ), 'default' => array( 'mphb_render_single_room_type_before_size' => '_renderSizeListItemOpen', 'mphb_render_single_room_type_after_size' => '_renderSizeListItemClose', ), ), 'bed-types' => array( 'label' => array( 'mphb_render_single_room_type_before_bed_type' => '_renderBedTypeTitle', ), 'default' => array( 'mphb_render_single_room_type_before_bed_type' => '_renderBedTypeListItemOpen', 'mphb_render_single_room_type_after_bed_type' => '_renderBedTypeListItemClose', ), ), 'categories' => array( 'label' => array( 'mphb_render_single_room_type_before_categories' => '_renderCategoriesTitle', ), 'default' => array( 'mphb_render_single_room_type_before_categories' => '_renderCategoriesListItemOpen', 'mphb_render_single_room_type_after_categories' => '_renderCategoriesListItemClose', ), ), 'custom' => array( 'label' => array( 'mphb_render_single_room_type_before_custom_attribute' => '_renderCustomAttributesTitle', ), 'default' => array( 'mphb_render_single_room_type_before_custom_attribute' => '_renderCustomAttributesListItemOpen', 'mphb_render_single_room_type_after_custom_attribute' => '_renderCustomAttributesListItemClose', ), ), ); private static $attributes_setting_to_action = array( 'adults' => array( 'renderAdults' ), 'children' => array( 'renderChildren' ), 'capacity' => array( 'renderTotalCapacity' ), 'amenities' => array( 'renderFacilities' ), 'view' => array( 'renderView' ), 'size' => array( 'renderSize' ), 'bed-types' => array( 'renderBedType' ), 'categories' => array( 'renderCategories' ), ); public static function search_availability( $args = array() ) { $defaults = array( 'check_in_date' => '', 'check_out_date' => '', 'adults' => '', 'children' => '', 'attributes' => '', 'form_style' => 'default', 'class' => '', ); $args = wp_parse_args( $args, $defaults ); if ( 'default' !== $args['form_style'] ) { $args['class'] .= ' ' . $args['form_style']; } return do_shortcode( self::build_shortcode( 'mphb_availability_search', array( 'attributes' => $args['attributes'], 'check_in_date' => $args['check_in_date'], 'check_out_date' => $args['check_out_date'], 'adults' => $args['adults'], 'children' => $args['children'], 'class' => trim( $args['class'] ), ) ) ); } public static function rooms( $args = array() ) { $defaults = array( 'title' => '', 'featured_image' => '', 'gallery' => '', 'excerpt' => '', 'details' => '', 'price' => '', 'view_button' => '', 'book_button' => '', 'ids' => '', 'category' => '', 'tags' => '', 'relation' => '', 'posts_per_page' => '', 'orderby' => '', 'order' => '', 'meta_key' => '', 'meta_value' => '', 'class' => '', ); $args = wp_parse_args( $args, $defaults ); return do_shortcode( self::build_shortcode( 'mphb_rooms', $args ) ); } public static function single_accommodation( $args = array() ) { $defaults = array( 'title' => '', 'featured_image' => '', 'gallery' => '', 'excerpt' => '', 'details' => '', 'price' => '', 'view_button' => '', 'book_button' => '', 'id' => '', 'class' => '', ); $args = wp_parse_args( $args, $defaults ); if ( '' === $args['id'] ) { return esc_html__( 'Please insert accommodation id.', 'mphb-divi' ); } return do_shortcode( self::build_shortcode( 'mphb_room', $args ) ); } public static function services( $args = array() ) { $defaults = array( 'ids' => '', 'class' => '', 'posts_per_page' => '', 'orderby' => '', 'order' => '', 'meta_key' => '', 'meta_type' => '', ); $args = wp_parse_args( $args, $defaults ); return do_shortcode( self::build_shortcode( 'mphb_services', $args ) ); } public static function rates( $args = array() ) { $defaults = array( 'id' => '', 'class' => '', ); $args = wp_parse_args( $args, $defaults ); if ( '' === $args['id'] ) { return esc_html__( 'Please insert accommodation id.', 'mphb-divi' ); } return do_shortcode( self::build_shortcode( 'mphb_rates', $args ) ); } public static function booking_form( $args = array() ) { $defaults = array( 'id' => '', 'class' => '', 'form_style' => 'default', ); $args = wp_parse_args( $args, $defaults ); if ( 'default' !== $args['form_style'] ) { $args['class'] .= ' ' . $args['form_style']; } if ( '' === $args['id'] ) { return esc_html__( 'Please insert accommodation id.', 'mphb-divi' ); } return do_shortcode( self::build_shortcode( 'mphb_availability', array( 'class' => trim( $args['class'] ), 'id' => $args['id'], ) ) ); } public static function availability_calendar( $args = array() ) { $defaults = array( 'id' => '', 'monthstoshow' => '2,3', 'display_price' => false, 'truncate_price' => true, 'display_currency' => false, 'class' => '', ); $args = wp_parse_args( $args, $defaults ); if ( '' === $args['id'] ) { return esc_html__( 'Please insert accommodation id.', 'mphb-divi' ); } return do_shortcode( self::build_shortcode( 'mphb_availability_calendar', array( 'class' => $args['class'], 'id' => $args['id'], 'monthstoshow' => $args['monthstoshow'], 'display_price' => 'on' === $args['display_price'] ? 1 : 0, 'truncate_price' => 'on' === $args['truncate_price'] ? 1 : 0, 'display_currency' => 'on' === $args['display_currency'] ? 1 : 0, ) ) ); } public static function booking_confirmation( $args = array() ) { $args = wp_parse_args( $args, array( 'class' => '' ) ); return do_shortcode( self::build_shortcode( 'mphb_booking_confirmation', $args ) ); } public static function checkout( $args = array() ) { $args = wp_parse_args( $args, array( 'class' => '' ) ); return do_shortcode( self::build_shortcode( 'mphb_checkout', $args ) ); } public static function search_results( $args = array() ) { $defaults = array( 'title' => '', 'featured_image' => '', 'gallery' => '', 'excerpt' => '', 'details' => '', 'price' => '', 'view_button' => '', 'book_button' => '', 'orderby' => '', 'order' => '', 'meta_key' => '', 'meta_type' => '', 'default_sorting' => '', 'class' => '', ); $args = wp_parse_args( $args, $defaults ); return do_shortcode( self::build_shortcode( 'mphb_search_results', $args ) ); } public static function accommodation_title( $attrs = array() ) { $id = self::resolve_accommodation_id( $attrs ); if ( ! self::is_valid_room_type( $id ) ) { return ''; } $link_to_post = isset( $attrs['link_to_post'] ) && 'on' === $attrs['link_to_post']; if ( $link_to_post ) { add_action( 'mphb_render_single_room_type_before_title', array( __CLASS__, 'render_link_open' ), 15 ); add_action( 'mphb_render_single_room_type_after_title', array( __CLASS__, 'render_link_close' ), 5 ); } try { return self::render_room_type_query( $id, static function () { SingleRoomTypeView::renderTitle(); } ); } finally { if ( $link_to_post ) { remove_action( 'mphb_render_single_room_type_before_title', array( __CLASS__, 'render_link_open' ), 15 ); remove_action( 'mphb_render_single_room_type_after_title', array( __CLASS__, 'render_link_close' ), 5 ); } } } public static function accommodation_featured_image( $attrs = array() ) { $id = self::resolve_accommodation_id( $attrs ); if ( ! self::is_valid_room_type( $id ) ) { return ''; } $link_to_post = isset( $attrs['link_to_post'] ) && 'on' === $attrs['link_to_post']; $size = isset( $attrs['image_size'] ) ? $attrs['image_size'] : 'large'; return self::capture( static function () use ( $id, $link_to_post, $size ) { ?>
$id, 'post_type' => 'mphb_room_type', ) ); $output = self::capture( static function () use ( $query ) { if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); the_content(); } } } ); wp_reset_postdata(); return $output; } public static function accommodation_price( $attrs = array() ) { $id = self::resolve_accommodation_id( $attrs ); if ( ! self::is_valid_room_type( $id ) ) { return ''; } return self::with_room_type( $id, static function () { return self::capture( static function () { SingleRoomTypeView::renderDefaultOrForDatesPrice(); } ); } ); } public static function accommodation_gallery( $attrs = array() ) { $id = self::resolve_accommodation_id( $attrs ); if ( ! self::is_valid_room_type( $id ) ) { return ''; } $defaults = array( 'link_to' => '', 'columns' => '4', 'image_size' => '', 'is_lightbox' => '', ); self::$gallery_params = wp_parse_args( $attrs, $defaults ); self::$gallery_is_slider = isset( $attrs['is_slider'] ) && 'on' === $attrs['is_slider']; return self::with_room_type( $id, static function () { self::apply_gallery_filters(); try { return self::capture( static function () { if ( self::$gallery_is_slider ) { LoopRoomTypeView::renderGallery(); } else { SingleRoomTypeView::renderGallery(); } } ); } finally { self::restore_gallery_filters(); } } ); } public static function accommodation_attributes( $attrs = array() ) { $id = self::resolve_accommodation_id( $attrs ); if ( ! self::is_valid_room_type( $id ) ) { return ''; } $available_attributes = array_keys( self::get_accommodation_attributes() ); $selected_attributes = ! empty( $attrs['selected_attributes'] ) ? explode( ',', $attrs['selected_attributes'] ) : $available_attributes; self::$attributes_hidden = array_diff( $available_attributes, $selected_attributes ); self::$attributes_removed_actions = array(); return self::with_room_type( $id, static function () { self::apply_attributes_filters(); try { return self::capture( static function () { SingleRoomTypeView::renderAttributes(); } ); } finally { self::restore_attributes_filters(); } } ); } public static function accommodation_attribute( $attrs = array() ) { $id = self::resolve_accommodation_id( $attrs ); if ( ! self::is_valid_room_type( $id ) ) { return ''; } $attribute = isset( $attrs['selected_attribute'] ) ? $attrs['selected_attribute'] : 'adults'; $show_label = isset( $attrs['show_label'] ) && in_array( $attrs['show_label'], array( 'on', 'yes' ), true ); self::$attribute_removed_actions = array(); return self::with_room_type( $id, static function () use ( $attribute, $show_label ) { return self::capture( static function () use ( $attribute, $show_label ) { self::render_attribute( $attribute, $show_label ); } ); } ); } public static function render_link_open() { ?>