business-hours.php
416 lines
| 1 | <?php |
| 2 | namespace Elementor; |
| 3 | |
| 4 | use \Elementor\ElementsKit_Widget_Business_Hours_Handler as Handler; |
| 5 | use \ElementsKit_Lite\Modules\Controls\Controls_Manager as ElementsKit_Controls_Manager; |
| 6 | |
| 7 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 8 | |
| 9 | |
| 10 | class ElementsKit_Widget_Business_Hours extends Widget_Base { |
| 11 | use \ElementsKit_Lite\Widgets\Widget_Notice; |
| 12 | |
| 13 | public $base; |
| 14 | |
| 15 | public function get_name() { |
| 16 | return Handler::get_name(); |
| 17 | } |
| 18 | |
| 19 | public function get_title() { |
| 20 | return Handler::get_title(); |
| 21 | } |
| 22 | |
| 23 | public function get_icon() { |
| 24 | return Handler::get_icon(); |
| 25 | } |
| 26 | |
| 27 | public function get_categories() { |
| 28 | return Handler::get_categories(); |
| 29 | } |
| 30 | |
| 31 | public function get_keywords() { |
| 32 | return Handler::get_keywords(); |
| 33 | } |
| 34 | |
| 35 | public function get_help_url() { |
| 36 | return 'https://wpmet.com/doc/business-hours/'; |
| 37 | } |
| 38 | |
| 39 | public function get_style_depends() { |
| 40 | return ['ekit-business-hours']; |
| 41 | } |
| 42 | |
| 43 | protected function is_dynamic_content(): bool { |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | public function has_widget_inner_wrapper(): bool { |
| 48 | return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); |
| 49 | } |
| 50 | |
| 51 | protected function register_controls() { |
| 52 | |
| 53 | |
| 54 | $this->start_controls_section( |
| 55 | 'ekit_btn_section_content', |
| 56 | array( |
| 57 | 'label' => esc_html__( 'Content', 'elementskit-lite' ), |
| 58 | ) |
| 59 | ); |
| 60 | |
| 61 | $repeater = new Repeater(); |
| 62 | |
| 63 | $repeater->add_control( |
| 64 | 'ekit_business_day', |
| 65 | [ |
| 66 | 'label' => esc_html__( 'Day', 'elementskit-lite' ), |
| 67 | 'type' => Controls_Manager::TEXT, |
| 68 | 'dynamic' => [ |
| 69 | 'active' => true, |
| 70 | ], |
| 71 | 'default' => esc_html__( 'Saturday', 'elementskit-lite' ), |
| 72 | ] |
| 73 | ); |
| 74 | |
| 75 | $repeater->add_control( |
| 76 | 'ekit_business_time', |
| 77 | [ |
| 78 | 'label' => esc_html__( 'Time', 'elementskit-lite' ), |
| 79 | 'type' => Controls_Manager::TEXTAREA, |
| 80 | 'dynamic' => [ |
| 81 | 'active' => true, |
| 82 | ], |
| 83 | 'default' => esc_html__( '9:00 AM - 6:00 PM', 'elementskit-lite' ), |
| 84 | ] |
| 85 | ); |
| 86 | |
| 87 | $repeater->add_control( |
| 88 | 'ekit_highlight_this_day', |
| 89 | [ |
| 90 | 'label' => esc_html__( 'Highlight this day', 'elementskit-lite' ), |
| 91 | 'type' => Controls_Manager::SWITCHER, |
| 92 | 'return_value' => 'yes', |
| 93 | 'default' => 'no', |
| 94 | 'separator' => 'before', |
| 95 | ] |
| 96 | ); |
| 97 | |
| 98 | $repeater->add_responsive_control( |
| 99 | 'ekit_single_business_day_color', |
| 100 | [ |
| 101 | 'label' => esc_html__( 'Day Color', 'elementskit-lite' ), |
| 102 | 'type' => Controls_Manager::COLOR, |
| 103 | 'default' => '#fa2d2d', |
| 104 | 'selectors' => [ |
| 105 | '{{WRAPPER}} .ekit-wid-con {{CURRENT_ITEM}}.ekit-closed-day.ekit-single-day .ekit-business-day' => 'color: {{VALUE}}', |
| 106 | ], |
| 107 | 'condition' => [ |
| 108 | 'ekit_highlight_this_day' => 'yes', |
| 109 | ], |
| 110 | 'separator' => 'before', |
| 111 | ] |
| 112 | ); |
| 113 | |
| 114 | $repeater->add_responsive_control( |
| 115 | 'ekit_single_business_time_color', |
| 116 | [ |
| 117 | 'label' => esc_html__( 'Time Color', 'elementskit-lite' ), |
| 118 | 'type' => Controls_Manager::COLOR, |
| 119 | 'default' => '#fa2d2d', |
| 120 | 'selectors' => [ |
| 121 | '{{WRAPPER}} .ekit-wid-con {{CURRENT_ITEM}}.ekit-closed-day.ekit-single-day .ekit-business-time' => 'color: {{VALUE}}', |
| 122 | ], |
| 123 | 'condition' => [ |
| 124 | 'ekit_highlight_this_day' => 'yes', |
| 125 | ], |
| 126 | 'separator' => 'before', |
| 127 | ] |
| 128 | ); |
| 129 | |
| 130 | $repeater->add_responsive_control( |
| 131 | 'ekit_single_business_background_color', |
| 132 | [ |
| 133 | 'label' => esc_html__( 'Background Color', 'elementskit-lite' ), |
| 134 | 'type' => Controls_Manager::COLOR, |
| 135 | 'selectors' => [ |
| 136 | '{{WRAPPER}} .ekit-wid-con {{CURRENT_ITEM}}.ekit-closed-day' => 'background-color: {{VALUE}}', |
| 137 | ], |
| 138 | 'condition' => [ |
| 139 | 'ekit_highlight_this_day' => 'yes', |
| 140 | ], |
| 141 | 'separator' => 'before', |
| 142 | ] |
| 143 | ); |
| 144 | |
| 145 | $this->add_control( |
| 146 | 'ekit_business_openday_list', |
| 147 | [ |
| 148 | 'type' => Controls_Manager::REPEATER, |
| 149 | 'fields' => $repeater->get_controls(), |
| 150 | 'default' => [ |
| 151 | [ |
| 152 | 'ekit_business_day' => esc_html__( 'Sunday', 'elementskit-lite' ), |
| 153 | 'ekit_business_time' => esc_html__( 'Close','elementskit-lite' ), |
| 154 | 'ekit_highlight_this_day' => esc_html__( 'yes','elementskit-lite' ), |
| 155 | ], |
| 156 | |
| 157 | [ |
| 158 | 'ekit_business_day' => esc_html__( 'Saturday', 'elementskit-lite' ), |
| 159 | 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ), |
| 160 | 'ekit_highlight_this_day' => esc_html__( 'yes','elementskit-lite' ), |
| 161 | ], |
| 162 | |
| 163 | [ |
| 164 | 'ekit_business_day' => esc_html__( 'Monday', 'elementskit-lite' ), |
| 165 | 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ), |
| 166 | ], |
| 167 | |
| 168 | [ |
| 169 | 'ekit_business_day' => esc_html__( 'Tues Day', 'elementskit-lite' ), |
| 170 | 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ), |
| 171 | ], |
| 172 | |
| 173 | [ |
| 174 | 'ekit_business_day' => esc_html__( 'Wednesday', 'elementskit-lite' ), |
| 175 | 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ), |
| 176 | ], |
| 177 | |
| 178 | [ |
| 179 | 'ekit_business_day' => esc_html__( 'Thursday', 'elementskit-lite' ), |
| 180 | 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ), |
| 181 | ], |
| 182 | |
| 183 | [ |
| 184 | 'ekit_business_day' => esc_html__( 'Friday', 'elementskit-lite' ), |
| 185 | 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ), |
| 186 | ] |
| 187 | ], |
| 188 | 'title_field' => '{{{ ekit_business_day }}}', |
| 189 | ] |
| 190 | ); |
| 191 | |
| 192 | $this->end_controls_section(); |
| 193 | |
| 194 | |
| 195 | // Style Item section |
| 196 | $this->start_controls_section( |
| 197 | 'ekit_business_item_style_section', |
| 198 | [ |
| 199 | 'label' => esc_html__( 'Item', 'elementskit-lite' ), |
| 200 | 'tab' => Controls_Manager::TAB_STYLE, |
| 201 | ] |
| 202 | ); |
| 203 | |
| 204 | $this->add_responsive_control( |
| 205 | 'ekit_business_item_margin', |
| 206 | [ |
| 207 | 'label' => esc_html__( 'Margin', 'elementskit-lite' ), |
| 208 | 'type' => Controls_Manager::DIMENSIONS, |
| 209 | 'size_units' => [ 'px', '%', 'em' ], |
| 210 | 'selectors' => [ |
| 211 | '{{WRAPPER}} .ekit-wid-con .ekit-single-day' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 212 | ], |
| 213 | 'separator' =>'before', |
| 214 | ] |
| 215 | ); |
| 216 | |
| 217 | $this->add_responsive_control( |
| 218 | 'ekit_business_item_padding', |
| 219 | [ |
| 220 | 'label' => esc_html__( 'Padding', 'elementskit-lite' ), |
| 221 | 'type' => Controls_Manager::DIMENSIONS, |
| 222 | 'size_units' => [ 'px', '%', 'em' ], |
| 223 | 'selectors' => [ |
| 224 | '{{WRAPPER}} .ekit-wid-con .ekit-single-day' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 225 | ], |
| 226 | 'separator' =>'after', |
| 227 | ] |
| 228 | ); |
| 229 | |
| 230 | $this->add_group_control( |
| 231 | Group_Control_Background::get_type(), |
| 232 | [ |
| 233 | 'name' => 'ekit_business_item_background', |
| 234 | 'label' => esc_html__( 'Background', 'elementskit-lite' ), |
| 235 | 'types' => [ 'classic', 'gradient' ], |
| 236 | 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day', |
| 237 | ] |
| 238 | ); |
| 239 | |
| 240 | $this->add_responsive_control( |
| 241 | 'ekit_business_item_item_radius', |
| 242 | [ |
| 243 | 'label' => esc_html__( 'Border Radius', 'elementskit-lite' ), |
| 244 | 'type' => Controls_Manager::DIMENSIONS, |
| 245 | 'size_units' => [ 'px', '%', 'em' ], |
| 246 | 'selectors' => [ |
| 247 | '{{WRAPPER}} .ekit-wid-con .ekit-single-day' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 248 | ], |
| 249 | ] |
| 250 | ); |
| 251 | |
| 252 | $this->add_group_control( |
| 253 | Group_Control_Border::get_type(), |
| 254 | [ |
| 255 | 'name' => 'ekit_business_item_border', |
| 256 | 'label' => esc_html__( 'Border', 'elementskit-lite' ), |
| 257 | 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day:not(:last-child)', |
| 258 | ] |
| 259 | ); |
| 260 | |
| 261 | $this->end_controls_section(); |
| 262 | |
| 263 | // Style Business day section |
| 264 | $this->start_controls_section( |
| 265 | 'ekit_business_day_style_section', |
| 266 | [ |
| 267 | 'label' => esc_html__( 'Day', 'elementskit-lite' ), |
| 268 | 'tab' => Controls_Manager::TAB_STYLE, |
| 269 | ] |
| 270 | ); |
| 271 | |
| 272 | $this->add_responsive_control( |
| 273 | 'ekit_business_day_color', |
| 274 | [ |
| 275 | 'label' => esc_html__( 'Color', 'elementskit-lite' ), |
| 276 | 'type' => Controls_Manager::COLOR, |
| 277 | 'selectors' => [ |
| 278 | '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-day' => 'color: {{VALUE}};', |
| 279 | ], |
| 280 | ] |
| 281 | ); |
| 282 | $this->add_group_control( |
| 283 | Group_Control_Typography::get_type(), |
| 284 | [ |
| 285 | 'name' => 'ekit_business_day_typography', |
| 286 | 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-day', |
| 287 | ] |
| 288 | ); |
| 289 | |
| 290 | $this->add_group_control( |
| 291 | Group_Control_Background::get_type(), |
| 292 | [ |
| 293 | 'name' => 'ekit_business_day_background', |
| 294 | 'label' => esc_html__( 'Background', 'elementskit-lite' ), |
| 295 | 'types' => [ 'classic', 'gradient' ], |
| 296 | 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-day', |
| 297 | ] |
| 298 | ); |
| 299 | |
| 300 | $this->add_responsive_control( |
| 301 | 'ekit_business_item_day_radius', |
| 302 | [ |
| 303 | 'label' => esc_html__( 'Border Radius', 'elementskit-lite' ), |
| 304 | 'type' => Controls_Manager::DIMENSIONS, |
| 305 | 'size_units' => [ 'px', '%', 'em' ], |
| 306 | 'selectors' => [ |
| 307 | '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-day' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 308 | ], |
| 309 | ] |
| 310 | ); |
| 311 | |
| 312 | $this->add_responsive_control( |
| 313 | 'ekit_business_item_day_padding', |
| 314 | [ |
| 315 | 'label' => esc_html__( 'Padding', 'elementskit-lite' ), |
| 316 | 'type' => Controls_Manager::DIMENSIONS, |
| 317 | 'size_units' => [ 'px', '%', 'em' ], |
| 318 | 'selectors' => [ |
| 319 | '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-day' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 320 | ], |
| 321 | ] |
| 322 | ); |
| 323 | |
| 324 | $this->end_controls_section(); |
| 325 | |
| 326 | // Style Business Time section |
| 327 | $this->start_controls_section( |
| 328 | 'ekit_business_time_style_section', |
| 329 | [ |
| 330 | 'label' => esc_html__( 'Time', 'elementskit-lite' ), |
| 331 | 'tab' => Controls_Manager::TAB_STYLE, |
| 332 | ] |
| 333 | ); |
| 334 | |
| 335 | $this->add_responsive_control( |
| 336 | 'ekit_business_time_color', |
| 337 | [ |
| 338 | 'label' => esc_html__( 'Color', 'elementskit-lite' ), |
| 339 | 'type' => Controls_Manager::COLOR, |
| 340 | 'selectors' => [ |
| 341 | '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-time' => 'color: {{VALUE}};', |
| 342 | ], |
| 343 | ] |
| 344 | ); |
| 345 | $this->add_group_control( |
| 346 | Group_Control_Typography::get_type(), |
| 347 | [ |
| 348 | 'name' => 'ekit_business_time_typography', |
| 349 | 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-time', |
| 350 | ] |
| 351 | ); |
| 352 | |
| 353 | $this->add_group_control( |
| 354 | Group_Control_Background::get_type(), |
| 355 | [ |
| 356 | 'name' => 'ekit_business_time_background', |
| 357 | 'label' => esc_html__( 'Background', 'elementskit-lite' ), |
| 358 | 'types' => [ 'classic', 'gradient' ], |
| 359 | 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-time', |
| 360 | ] |
| 361 | ); |
| 362 | |
| 363 | $this->add_responsive_control( |
| 364 | 'ekit_business_item_time_radius', |
| 365 | [ |
| 366 | 'label' => esc_html__( 'Border Radius', 'elementskit-lite' ), |
| 367 | 'type' => Controls_Manager::DIMENSIONS, |
| 368 | 'size_units' => [ 'px', '%', 'em' ], |
| 369 | 'selectors' => [ |
| 370 | '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-time' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 371 | ], |
| 372 | ] |
| 373 | ); |
| 374 | |
| 375 | $this->add_responsive_control( |
| 376 | 'ekit_business_item_time_padding', |
| 377 | [ |
| 378 | 'label' => esc_html__( 'Padding', 'elementskit-lite' ), |
| 379 | 'type' => Controls_Manager::DIMENSIONS, |
| 380 | 'size_units' => [ 'px', '%', 'em' ], |
| 381 | 'selectors' => [ |
| 382 | '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-time' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 383 | ], |
| 384 | ] |
| 385 | ); |
| 386 | |
| 387 | |
| 388 | $this->end_controls_section(); |
| 389 | |
| 390 | $this->insert_pro_message(); |
| 391 | } |
| 392 | |
| 393 | protected function render( ) { |
| 394 | echo '<div class="ekit-wid-con" >'; |
| 395 | $this->render_raw(); |
| 396 | echo '</div>'; |
| 397 | } |
| 398 | |
| 399 | protected function render_raw( ) { |
| 400 | $settings = $this->get_settings_for_display(); |
| 401 | ?> |
| 402 | <div class="ekit-business-hours-inner"> |
| 403 | <?php foreach ($settings['ekit_business_openday_list'] as $item) : ?> |
| 404 | <div class="ekit-single-day elementor-repeater-item-<?php echo esc_attr($item['_id']); ?> <?php if( $item['ekit_highlight_this_day'] == 'yes' ){ echo esc_attr( 'ekit-closed-day','elementskit-lite'); }?>"> |
| 405 | <?php if( !empty( $item['ekit_business_day'] ) ) : ?> |
| 406 | <span class="ekit-business-day"><?php echo esc_html($item['ekit_business_day']); ?></span> |
| 407 | <?php endif; if( !empty( $item['ekit_business_time'] ) ): ?> |
| 408 | <span class="ekit-business-time"><?php echo esc_html($item['ekit_business_time']); ?></span> |
| 409 | <?php endif; ?> |
| 410 | </div> |
| 411 | <?php endforeach; ?> |
| 412 | </div> |
| 413 | <?php |
| 414 | } |
| 415 | } |
| 416 |