PluginProbe
Easy Hotel – Powerful Hotel Booking / trunk
Easy Hotel – Powerful Hotel Booking vtrunk
2.0.8 2.0.7 2.0.6 2.0.5 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.9.9 1.9.8 1.9.7 1.9.6 1.9.5 1.9.4 1.9.3 1.9.2 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 All 110 releases
easy-hotel / admin / includes / shortcodes.php

shortcodes.php in Easy Hotel – Powerful Hotel Booking trunk, at admin/includes/shortcodes.php

151 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3 function eshb_search_form_shortcode() {
4
5 // Ensure the class exists before attempting to use it
6 if (class_exists('ESHB_View')) {
7 ob_start();
8
9 include ESHB_PL_PATH . 'public/templates/easy-hotel-search.php';
10
11 return ob_get_clean();
12 } else {
13 return __('ESHB_View class not found.', 'easy-hotel');
14 }
15 }
16
17 // Register the shortcode
18 add_shortcode('eshb_search_form', 'eshb_search_form_shortcode');
19
20
21
22 // Accomodation Grid
23 function eshb_accomodation_grid_shortcode() {
24 if (class_exists('ESHB_View')) {
25 // Start output buffering
26 ob_start();
27
28 include ESHB_PL_PATH . 'public/templates/easy-hotel-archive.php';
29
30 // Capture the output and clean buffer
31 return ob_get_clean();
32 }
33
34 // Return empty string if the class doesn't exist
35 return '';
36 }
37
38 add_shortcode('eshb_accomodation_grid', 'eshb_accomodation_grid_shortcode');
39
40
41
42 // Accomodation Grid
43 function eshb_accomodation_search_result_shortcode() {
44 if (class_exists('ESHB_View')) {
45 // Start output buffering
46 ob_start();
47
48 include ESHB_PL_PATH . 'public/templates/template-parts/search-results-contents.php';
49
50 // Capture the output and clean buffer
51 return ob_get_clean();
52 }
53
54 // Return empty string if the class doesn't exist
55 return '';
56 }
57
58 add_shortcode('eshb_accomodation_search_result', 'eshb_accomodation_search_result_shortcode');
59
60
61 // Accommodation Info Shortcode
62 function eshb_accomodation_info_shortcode() {
63 $accomodation_id = get_the_ID();
64 $eshb_accomodation_metaboxes = get_post_meta($accomodation_id, 'eshb_accomodation_metaboxes', true);
65 $output = '<div class="basic-information-list">';
66
67 if ( ! empty( $eshb_accomodation_metaboxes['accomodation_info_group'] ) ) {
68 foreach ( $eshb_accomodation_metaboxes['accomodation_info_group'] as $group ) {
69 $icon = !empty($group['info_icon']) ? '<i class="info-icon ' . esc_html($group['info_icon']) . '"></i>' : '';
70 $img = !empty($group['info_icon_img']['url']) ? '<img src="' . esc_url($group['info_icon_img']['url']) . '" class="info-icon"> ' : '';
71 $title = esc_html($group['info_title']);
72 $output .= "<p class='info'>{$icon}{$img}<span class='info-title'>{$title}</span></p>";
73 }
74 }
75
76 return $output . '</div>';
77 }
78 add_shortcode('eshb_accomodation_info', 'eshb_accomodation_info_shortcode');
79
80 // Booking Form Shortcode
81 function eshb_booking_form_shortcode($atts) {
82 // Create a new instance of the ESHB_View class
83 $defaults = array(
84 'accomodation_id' => '',
85 'style' => 'style-one',
86 );
87
88 $atts = shortcode_atts($defaults, $atts);
89
90 $view = new ESHB_View();
91
92 return $view->eshb_get_booking_form_html($atts['accomodation_id'], $atts['style']);
93 }
94 add_shortcode('eshb_booking_form', 'eshb_booking_form_shortcode');
95
96 // Availability Calendar Shortcode
97 function eshb_availability_calendar_shortcode($atts) {
98
99 $defaults = array(
100 'accomodation_id' => get_the_ID(),
101 'style' => 'style-one',
102 );
103
104 $atts = shortcode_atts($defaults, $atts);
105
106 $view = new ESHB_View();
107
108 return $view->eshb_get_availability_calendar_html($atts['accomodation_id'], $atts['style']);
109 }
110 add_shortcode('eshb_availability_calendar', 'eshb_availability_calendar_shortcode');
111
112 // Related Rooms Shortcode
113 function eshb_related_accomodations_shortcode() {
114 if(is_singular( 'eshb_accomodation')) {
115 ob_start();
116 require ESHB_PL_PATH . 'public/templates/template-parts/related-room-slider.php';
117 return ob_get_clean();
118 }
119 }
120 add_shortcode('eshb_related_accomodations', 'eshb_related_accomodations_shortcode');
121
122
123
124 // Daywise Pricing Table Shortcode
125 function eshb_daywise_pricing_table_shortcode($atts) {
126 // Create a new instance of the ESHB_View class
127 $defaults = array(
128 'accomodation_id' => get_the_ID(),
129 'show_title' => false,
130 );
131
132 $atts = shortcode_atts($defaults, $atts);
133
134 $view = new ESHB_View();
135 ob_start();
136 $view->eshb_day_wise_pricing_table_html($atts['accomodation_id'], $atts['show_title']);
137 $output = ob_get_clean();
138 return $output;
139 }
140 add_shortcode('eshb_daywise_pricing_table', 'eshb_daywise_pricing_table_shortcode');
141
142 // Check In/Out Times Shortcode
143 function eshb_check_in_out_times_shortcode() {
144 // Create a new instance of the ESHB_View class
145 $view = new ESHB_View();
146 ob_start();
147 $view->eshb_get_eshb_check_in_out_times_html();
148 $output = ob_get_clean();
149 return $output;
150 }
151 add_shortcode('eshb_check_in_out_times', 'eshb_check_in_out_times_shortcode');