| 1 |
<?php |
| 2 |
defined('ABSPATH') || die(); |
| 3 |
class Eshb_Room_Basic_Info_Widget extends \Elementor\Widget_Base { |
| 4 |
/** |
| 5 |
* Get widget name. |
| 6 |
* |
| 7 |
* |
| 8 |
* @since 1.0.0 |
| 9 |
* @access public |
| 10 |
* |
| 11 |
* @return string Widget name. |
| 12 |
*/ |
| 13 |
|
| 14 |
public function get_name() |
| 15 |
{ |
| 16 |
return 'eshb-room-basic-info'; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Get widget title. |
| 21 |
* |
| 22 |
* @since 1.0.0 |
| 23 |
* @access public |
| 24 |
* |
| 25 |
* @return string Widget title. |
| 26 |
*/ |
| 27 |
|
| 28 |
public function get_title() |
| 29 |
{ |
| 30 |
return esc_html__('Easy Hotel Room Basic Info', 'easy-hotel'); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Get widget icon. |
| 35 |
* |
| 36 |
* @since 1.0.0 |
| 37 |
* @access public |
| 38 |
* |
| 39 |
* @return string Widget icon. |
| 40 |
*/ |
| 41 |
public function get_icon() { |
| 42 |
return 'easy-hotel-widget-icon'; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
public function get_categories() { |
| 47 |
return [ 'easy_hotel_category' ]; |
| 48 |
} |
| 49 |
|
| 50 |
public function get_keywords() |
| 51 |
{ |
| 52 |
return ['room_basic_info']; |
| 53 |
} |
| 54 |
protected function register_controls() |
| 55 |
{ |
| 56 |
|
| 57 |
|
| 58 |
$this->start_controls_section( |
| 59 |
'content_room_basic_info', |
| 60 |
[ |
| 61 |
'label' => esc_html__('Room Basic Info Settings', 'easy-hotel'), |
| 62 |
'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 63 |
] |
| 64 |
); |
| 65 |
|
| 66 |
$this->add_control( |
| 67 |
'show_price', |
| 68 |
[ |
| 69 |
'label' => esc_html__( 'Show Price', 'easy-hotel' ), |
| 70 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 71 |
'label_on' => esc_html__( 'Show', 'easy-hotel' ), |
| 72 |
'label_off' => esc_html__( 'Hide', 'easy-hotel' ), |
| 73 |
'return_value' => 'yes', |
| 74 |
'default' => 'yes', |
| 75 |
] |
| 76 |
); |
| 77 |
|
| 78 |
$this->end_controls_section(); |
| 79 |
|
| 80 |
$this->start_controls_section( |
| 81 |
'wrapper_style', |
| 82 |
[ |
| 83 |
'label' => esc_html__( 'Wrapper', 'easy-hotel' ), |
| 84 |
'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 85 |
] |
| 86 |
); |
| 87 |
$this->add_control( |
| 88 |
'wrapper_bg_color', |
| 89 |
[ |
| 90 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 91 |
'label' => esc_html__( 'Background Color', 'easy-hotel' ), |
| 92 |
'default' => '#ffffff', |
| 93 |
'selectors' => [ |
| 94 |
'{{WRAPPER}} .eshb-basic-information-wrapper' => 'background-color: {{VALUE}}', |
| 95 |
], |
| 96 |
] |
| 97 |
); |
| 98 |
$this->add_responsive_control( |
| 99 |
'wrapper_padding', |
| 100 |
[ |
| 101 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 102 |
'label' => esc_html__( 'Padding', 'easy-hotel' ), |
| 103 |
'size_units' => [ 'px', 'em', '%' ], |
| 104 |
'selectors' => [ |
| 105 |
'{{WRAPPER}} .eshb-basic-information-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 106 |
], |
| 107 |
] |
| 108 |
); |
| 109 |
$this->add_group_control( |
| 110 |
\Elementor\Group_Control_Border::get_type(), |
| 111 |
[ |
| 112 |
'name' => 'border', |
| 113 |
'selector' => '{{WRAPPER}} .eshb-basic-information-wrapper', |
| 114 |
] |
| 115 |
); |
| 116 |
$this->add_responsive_control( |
| 117 |
'wrapper_border_radius', |
| 118 |
[ |
| 119 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 120 |
'label' => esc_html__( 'Border Radius', 'easy-hotel' ), |
| 121 |
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 122 |
'selectors' => [ |
| 123 |
'{{WRAPPER}} .eshb-basic-information-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;', |
| 124 |
], |
| 125 |
] |
| 126 |
); |
| 127 |
|
| 128 |
$this->add_responsive_control( |
| 129 |
'justify_content', |
| 130 |
[ |
| 131 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 132 |
'label' => esc_html__( 'Justify Content', 'easy-hotel' ), |
| 133 |
'options' => [ |
| 134 |
'flex-start' => [ |
| 135 |
'title' => esc_html__( 'Start', 'easy-hotel' ), |
| 136 |
'icon' => 'eicon-flex eicon-justify-start-h', |
| 137 |
], |
| 138 |
'center' => [ |
| 139 |
'title' => esc_html__( 'Center', 'easy-hotel' ), |
| 140 |
'icon' => 'eicon-flex eicon-justify-center-h', |
| 141 |
], |
| 142 |
'flex-end' => [ |
| 143 |
'title' => esc_html__( 'End', 'easy-hotel' ), |
| 144 |
'icon' => 'eicon-flex eicon-justify-end-h', |
| 145 |
], |
| 146 |
'space-between' => [ |
| 147 |
'title' => esc_html__( 'Space Between', 'easy-hotel' ), |
| 148 |
'icon' => 'eicon-flex eicon-justify-space-between-h', |
| 149 |
], |
| 150 |
], |
| 151 |
'selectors' => [ |
| 152 |
'{{WRAPPER}} .basic-information-list' => 'justify-content: {{VALUE}};', |
| 153 |
], |
| 154 |
] |
| 155 |
); |
| 156 |
|
| 157 |
$this->end_controls_section(); |
| 158 |
|
| 159 |
$this->start_controls_section( |
| 160 |
'item_style', |
| 161 |
[ |
| 162 |
'label' => esc_html__( 'Item', 'easy-hotel' ), |
| 163 |
'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 164 |
] |
| 165 |
); |
| 166 |
$this->add_responsive_control( |
| 167 |
'items_space_between', |
| 168 |
[ |
| 169 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 170 |
'label' => esc_html__( 'Space Between', 'easy-hotel' ), |
| 171 |
'size_units' => [ 'px', 'em', 'rem', 'custom' ], |
| 172 |
'default' => [ |
| 173 |
'unit' => 'px', |
| 174 |
'size' => 20, |
| 175 |
], |
| 176 |
'range' => [ |
| 177 |
'px' => [ |
| 178 |
'min' => 0, |
| 179 |
'max' => 300, |
| 180 |
], |
| 181 |
], |
| 182 |
'selectors' => [ |
| 183 |
'{{WRAPPER}} .eshb-basic-information-wrapper .basic-information-list' => 'gap: {{SIZE}}{{UNIT}}', |
| 184 |
], |
| 185 |
] |
| 186 |
); |
| 187 |
$this->end_controls_section(); |
| 188 |
|
| 189 |
$this->start_controls_section( |
| 190 |
'icon_style', |
| 191 |
[ |
| 192 |
'label' => esc_html__( 'Icon', 'easy-hotel' ), |
| 193 |
'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 194 |
] |
| 195 |
); |
| 196 |
$this->add_control( |
| 197 |
'icon_color', |
| 198 |
[ |
| 199 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 200 |
'label' => esc_html__( 'Color', 'easy-hotel' ), |
| 201 |
'selectors' => [ |
| 202 |
'{{WRAPPER}} .eshb-basic-information-wrapper .basic-information-list .info-icon' => 'color: {{VALUE}}', |
| 203 |
], |
| 204 |
] |
| 205 |
); |
| 206 |
$this->add_control( |
| 207 |
'icon_size', |
| 208 |
[ |
| 209 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 210 |
'label' => esc_html__( 'Size', 'easy-hotel' ), |
| 211 |
'size_units' => [ 'px', 'em', 'rem', 'custom' ], |
| 212 |
'default' => [ |
| 213 |
'unit' => 'px', |
| 214 |
'size' => 20, |
| 215 |
], |
| 216 |
'range' => [ |
| 217 |
'px' => [ |
| 218 |
'min' => 0, |
| 219 |
'max' => 300, |
| 220 |
], |
| 221 |
], |
| 222 |
'selectors' => [ |
| 223 |
'{{WRAPPER}} .eshb-basic-information-wrapper .basic-information-list .info-icon' => 'font-size: {{SIZE}}{{UNIT}}', |
| 224 |
'{{WRAPPER}} .eshb-basic-information-wrapper .basic-information-list img.info-icon' => 'height: {{SIZE}}{{UNIT}}', |
| 225 |
], |
| 226 |
] |
| 227 |
); |
| 228 |
$this->add_control( |
| 229 |
'icon_space_between', |
| 230 |
[ |
| 231 |
'type' => \Elementor\Controls_Manager::SLIDER, |
| 232 |
'label' => esc_html__( 'Space Between', 'easy-hotel' ), |
| 233 |
'size_units' => [ 'px', 'em', 'rem', 'custom' ], |
| 234 |
'default' => [ |
| 235 |
'unit' => 'px', |
| 236 |
'size' => 20, |
| 237 |
], |
| 238 |
'range' => [ |
| 239 |
'px' => [ |
| 240 |
'min' => 0, |
| 241 |
'max' => 300, |
| 242 |
], |
| 243 |
], |
| 244 |
'selectors' => [ |
| 245 |
'{{WRAPPER}} .eshb-basic-information-wrapper .basic-information-list .info' => 'gap: {{SIZE}}{{UNIT}}', |
| 246 |
], |
| 247 |
] |
| 248 |
); |
| 249 |
$this->end_controls_section(); |
| 250 |
|
| 251 |
$this->start_controls_section( |
| 252 |
'label_style', |
| 253 |
[ |
| 254 |
'label' => esc_html__( 'Label', 'easy-hotel' ), |
| 255 |
'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 256 |
] |
| 257 |
); |
| 258 |
$this->add_control( |
| 259 |
'label_color', |
| 260 |
[ |
| 261 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 262 |
'label' => esc_html__( 'Color', 'easy-hotel' ), |
| 263 |
'selectors' => [ |
| 264 |
'{{WRAPPER}} .eshb-basic-information-wrapper .basic-information-list .info' => 'color: {{VALUE}}', |
| 265 |
], |
| 266 |
] |
| 267 |
); |
| 268 |
$this->add_group_control( |
| 269 |
\Elementor\Group_Control_Typography::get_type(), |
| 270 |
[ |
| 271 |
'name' => 'label_typography', |
| 272 |
'selector' => '{{WRAPPER}} .eshb-basic-information-wrapper .basic-information-list .info', |
| 273 |
] |
| 274 |
); |
| 275 |
$this->end_controls_section(); |
| 276 |
|
| 277 |
$this->start_controls_section( |
| 278 |
'pricing_style', |
| 279 |
[ |
| 280 |
'label' => esc_html__( 'Pricing', 'easy-hotel' ), |
| 281 |
'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 282 |
] |
| 283 |
); |
| 284 |
|
| 285 |
$this->add_control( |
| 286 |
'pricing_color', |
| 287 |
[ |
| 288 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 289 |
'label' => esc_html__( 'Color', 'easy-hotel' ), |
| 290 |
'selectors' => [ |
| 291 |
'{{WRAPPER}} .eshb-basic-information-wrapper .price' => 'color: {{VALUE}}', |
| 292 |
], |
| 293 |
] |
| 294 |
); |
| 295 |
$this->add_group_control( |
| 296 |
\Elementor\Group_Control_Typography::get_type(), |
| 297 |
[ |
| 298 |
'name' => 'pricing_typography', |
| 299 |
'selector' => '{{WRAPPER}} .eshb-basic-information-wrapper .price', |
| 300 |
] |
| 301 |
); |
| 302 |
$this->add_control( |
| 303 |
'pricing_label', |
| 304 |
[ |
| 305 |
'label' => esc_html__( 'Label', 'easy-hotel' ), |
| 306 |
'type' => \Elementor\Controls_Manager::HEADING, |
| 307 |
'separator' => 'before', |
| 308 |
] |
| 309 |
); |
| 310 |
$this->add_control( |
| 311 |
'pricing_label_color', |
| 312 |
[ |
| 313 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 314 |
'label' => esc_html__( 'Color', 'easy-hotel' ), |
| 315 |
'selectors' => [ |
| 316 |
'{{WRAPPER}} .eshb-basic-information-wrapper .price .label' => 'color: {{VALUE}}', |
| 317 |
], |
| 318 |
] |
| 319 |
); |
| 320 |
$this->add_group_control( |
| 321 |
\Elementor\Group_Control_Typography::get_type(), |
| 322 |
[ |
| 323 |
'name' => 'pricing_label_typography', |
| 324 |
'selector' => '{{WRAPPER}} .eshb-basic-information-wrapper .price .label', |
| 325 |
] |
| 326 |
); |
| 327 |
$this->end_controls_section(); |
| 328 |
|
| 329 |
} |
| 330 |
|
| 331 |
|
| 332 |
protected function render() |
| 333 |
{ |
| 334 |
$settings = $this->get_settings_for_display(); |
| 335 |
$show_price = $settings['show_price']; |
| 336 |
$accomodation_id = get_the_ID(); |
| 337 |
|
| 338 |
$hotel_core = new ESHB_Core(); |
| 339 |
$price = $hotel_core->get_eshb_price_html('', '', $accomodation_id); |
| 340 |
$eshb_settings = get_option('eshb_settings'); |
| 341 |
$string_night = isset($eshb_settings['string_night']) && !empty($eshb_settings['string_night']) ? $eshb_settings['string_night'] : 'night'; |
| 342 |
$perodicity_string = apply_filters( 'eshb_perodicity_string_in_loop', $string_night, $accomodation_id, $eshb_settings); |
| 343 |
|
| 344 |
|
| 345 |
$eshb_accomodation_metaboxes = get_post_meta($accomodation_id, 'eshb_accomodation_metaboxes', true); |
| 346 |
|
| 347 |
|
| 348 |
$output = '<div class="eshb-basic-information-wrapper">'; |
| 349 |
$output .= '<div class="basic-information-list">'; |
| 350 |
|
| 351 |
if ( ! empty( $eshb_accomodation_metaboxes['accomodation_info_group'] ) ) { |
| 352 |
foreach ( $eshb_accomodation_metaboxes['accomodation_info_group'] as $group ) { |
| 353 |
$icon = !empty($group['info_icon']) ? '<i class="info-icon ' . esc_html($group['info_icon']) . '"></i>' : ''; |
| 354 |
$img = !empty($group['info_icon_img']['url']) ? '<img src="' . esc_url($group['info_icon_img']['url']) . '" class="info-icon"> ' : ''; |
| 355 |
$title = esc_html($group['info_title']); |
| 356 |
$output .= "<div class='info'>{$icon}{$img}<span class='info-title'>{$title}</span></div>"; |
| 357 |
} |
| 358 |
} |
| 359 |
if ($show_price == 'yes' && !empty($price)) { |
| 360 |
$output .= '<h3 class="price">' . wp_kses_post($price) . '<div class="label"> / ' . esc_html( eshb_get_translated_string($perodicity_string) ) . '</div></h3>'; |
| 361 |
} |
| 362 |
|
| 363 |
$output .= '</div>'; |
| 364 |
$output .= '</div>'; |
| 365 |
|
| 366 |
echo wp_kses_post( $output ); |
| 367 |
|
| 368 |
} |
| 369 |
} |