File: //home/parhudrw/roflma.it/wp-content/plugins/lesya-plugin/elementor/widgets/hours.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Lesya Hours Widget.
*
* @since 1.0
*/
class Lesya_Hours_Widget extends Widget_Base {
public function get_name() {
return 'lesya-hours';
}
public function get_title() {
return esc_html__( 'Hours', 'lesya-plugin' );
}
public function get_icon() {
return 'eicon-parallax';
}
public function get_categories() {
return [ 'lesya-category' ];
}
/**
* Register widget controls.
*
* @since 1.0
*/
protected function register_controls() {
$this->start_controls_section(
'content_tab',
[
'label' => esc_html__( 'Content', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'lesya-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'lesya-plugin' ),
'default' => esc_html__( 'Title', 'lesya-plugin' ),
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'subtitle',
[
'label' => esc_html__( 'Subtitle', 'lesya-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter subtitle', 'lesya-plugin' ),
'default' => esc_html__( 'Subtitle', 'lesya-plugin' ),
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'bg_text',
[
'label' => esc_html__( 'Background Title', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter title', 'lesya-plugin' ),
'default' => esc_html__( 'Title', 'lesya-plugin' ),
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'description',
[
'label' => esc_html__( 'Description', 'lesya-plugin' ),
'type' => Controls_Manager::WYSIWYG,
'placeholder' => esc_html__( 'Enter your description', 'lesya-plugin' ),
'default' => esc_html__( 'Description', 'lesya-plugin' ),
]
);
$this->add_control(
'button',
[
'label' => esc_html__( 'Button (Text)', 'lesya-plugin' ),
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter Button Label', 'lesya-plugin' ),
'default' => esc_html__( 'Button', 'lesya-plugin' ),
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'link',
[
'label' => esc_html__( 'Button (URL)', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::URL,
'show_external' => true,
'dynamic' => [
'active' => true,
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'images_tab',
[
'label' => esc_html__( 'Images', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'image',
[
'label' => esc_html__( 'Image', 'lesya-plugin' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'shapes_show',
[
'label' => esc_html__( 'Show Shapes', 'lesya-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'lesya-plugin' ),
'label_off' => __( 'Hide', 'lesya-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'image-circle',
[
'label' => esc_html__( 'Image Circle', 'lesya-plugin' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'shapes_show' => 'yes'
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'list_tab',
[
'label' => esc_html__( 'List', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'date', [
'label' => esc_html__( 'Date', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter date', 'lesya-plugin' ),
'default' => esc_html__( 'Date', 'lesya-plugin' ),
]
);
$repeater->add_control(
'dot', [
'label' => esc_html__( 'Symbol', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter symbol', 'lesya-plugin' ),
'default' => esc_html__( 'Symbol', 'lesya-plugin' ),
]
);
$repeater->add_control(
'time', [
'label' => esc_html__( 'Time', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter time', 'lesya-plugin' ),
'default' => esc_html__( 'Time', 'lesya-plugin' ),
]
);
$this->add_control(
'list',
[
'label' => esc_html__( 'List', 'lesya-plugin' ),
'type' => Controls_Manager::REPEATER,
'prevent_empty' => false,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ date }}}',
]
);
$this->end_controls_section();
$this->start_controls_section(
'content_styling',
[
'label' => esc_html__( 'Content Styling', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .section-title h2' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .section-title h2',
]
);
$this->add_control(
'subtitle_color',
[
'label' => esc_html__( 'Subtitle Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .section-title .sub-title' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'subtitle_typography',
'label' => esc_html__( 'Subtitle Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .section-title .sub-title',
]
);
$this->add_control(
'bgtext_color',
[
'label' => esc_html__( 'BG Text Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .section-title .bg-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'bgtext_typography',
'label' => esc_html__( 'BG Text Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .section-title .bg-text',
]
);
$this->add_control(
'description_color',
[
'label' => esc_html__( 'Description Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .booking-hours-content .description' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'description_typography',
'label' => esc_html__( 'Description Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .booking-hours-content .description',
]
);
$this->end_controls_section();
$this->start_controls_section(
'items_styling',
[
'label' => esc_html__( 'Items Styling', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'item_date_color',
[
'label' => esc_html__( 'Date Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .booking-hours-content .booking-hours li .date' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_date_typography',
'label' => esc_html__( 'Date Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .booking-hours-content .booking-hours li .date',
]
);
$this->add_control(
'item_symbol_color',
[
'label' => esc_html__( 'Symbol Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .booking-hours-content .booking-hours li .symbol' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_symbol_typography',
'label' => esc_html__( 'Symbol Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .booking-hours-content .booking-hours li .symbol',
]
);
$this->add_control(
'item_time_color',
[
'label' => esc_html__( 'Time Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .booking-hours-content .booking-hours li .time' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_time_typography',
'label' => esc_html__( 'Time Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .booking-hours-content .booking-hours li .time',
]
);
$this->end_controls_section();
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
$this->add_inline_editing_attributes( 'title', 'basic' );
$this->add_inline_editing_attributes( 'subtitle', 'basic' );
$this->add_inline_editing_attributes( 'bg_text', 'none' );
$this->add_inline_editing_attributes( 'description', 'advanced' );
$this->add_inline_editing_attributes( 'button', 'basic' );
?>
<!-- Booking Hours Section Start -->
<section class="booking-hours-area bg-light-gray rel z-1">
<?php if ( $settings['image'] ) : $image = wp_get_attachment_image_url( $settings['image']['id'], 'lesya_900xAuto' ); ?>
<div class="booking-hour-image" style="background-image: url(<?php echo esc_url( $image ); ?>);"></div>
<?php endif;?>
<div class="container">
<div class="row">
<div class="col-lg-6 offset-lg-6">
<div class="booking-hours-content py-150 rpt-0 rpb-100 wow fadeInLeft delay-0-2s">
<?php if ( $settings['bg_text'] || $settings['subtitle'] || $settings['title'] ) : ?>
<div class="section-title mb-30">
<?php if ( $settings['bg_text'] ) : ?>
<span class="bg-text">
<span <?php echo $this->get_render_attribute_string( 'bg_text' ); ?>>
<?php echo wp_kses_post( $settings['bg_text'] ); ?>
</span>
</span>
<?php endif; ?>
<?php if ( $settings['subtitle'] ) : ?>
<span class="sub-title">
<span <?php echo $this->get_render_attribute_string( 'subtitle' ); ?>>
<?php echo wp_kses_post( $settings['subtitle'] ); ?>
</span>
</span>
<?php endif; ?>
<?php if ( $settings['title'] ) : ?>
<h2>
<span <?php echo $this->get_render_attribute_string( 'title' ); ?>>
<?php echo wp_kses_post( $settings['title'] ); ?>
</span>
</h2>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( $settings['description'] ) : ?>
<div class="description">
<div <?php echo $this->get_render_attribute_string( 'description' ); ?>>
<?php echo wp_kses_post( $settings['description'] ); ?>
</div>
</div>
<?php endif; ?>
<?php if ( $settings['list'] ) : ?>
<ul class="booking-hours py-20 wow fadeInRight delay-0-2s">
<?php foreach ( $settings['list'] as $index => $item ) :
$item_date = $this->get_repeater_setting_key( 'date', 'list', $index );
$this->add_inline_editing_attributes( $item_date, 'basic' );
$item_dot = $this->get_repeater_setting_key( 'dot', 'list', $index );
$this->add_inline_editing_attributes( $item_dot, 'basic' );
$item_time = $this->get_repeater_setting_key( 'time', 'list', $index );
$this->add_inline_editing_attributes( $item_time, 'basic' );
?>
<li>
<span class="date" <?php echo $this->get_render_attribute_string( $item_date ); ?>><?php echo wp_kses_post( $item['date'] ); ?></span>
<span class="symbol" <?php echo $this->get_render_attribute_string( $item_dot ); ?>><?php echo wp_kses_post( $item['dot'] ); ?></span>
<span class="time" <?php echo $this->get_render_attribute_string( $item_time ); ?>><?php echo wp_kses_post( $item['time'] ); ?></span>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php if ( $settings['button'] ) : ?>
<a<?php if ( $settings['link'] ) : ?><?php if ( $settings['link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $settings['link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $settings['link']['url'] ); ?>"<?php endif; ?> class="theme-btn style-two">
<span <?php echo $this->get_render_attribute_string( 'button' ); ?>>
<?php echo esc_html( $settings['button'] ); ?>
</span>
<i class="fas fa-long-arrow-alt-right"></i>
</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php if ( $settings['shapes_show'] == 'yes' ) : ?>
<?php if ( $settings['image-circle'] ) : $image_circle = wp_get_attachment_image_url( $settings['image-circle']['id'], 'full' ); ?>
<div class="booking-circle">
<img src="<?php echo esc_url( $image_circle ); ?>" alt="<?php echo esc_attr( $settings['title'] ); ?>">
</div>
<?php endif; ?>
<div class="booking-bg-icon">
<i class="flaticon-hair-iron"></i>
</div>
<?php endif; ?>
</section>
<!-- Booking Hours Section End -->
<?php
}
/**
* Render widget output in the editor.
*
* Written as a Backbone JavaScript template and used to generate the live preview.
*
* @since 1.0.0
* @access protected
*/
/*protected function content_template() { ?>
<?php }*/
}
Plugin::instance()->widgets_manager->register_widget_type( new Lesya_Hours_Widget() );