File: /home/parhudrw/roflma.it/wp-content/plugins/lesya-plugin/elementor/widgets/services.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Lesya Services Widget.
*
* @since 1.0
*/
class Lesya_Services_Widget extends Widget_Base {
public function get_name() {
return 'lesya-services';
}
public function get_title() {
return esc_html__( 'Services', '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(
'items_tab',
[
'label' => esc_html__( 'Items', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'icon', [
'label' => esc_html__( 'Icon', 'lesya-plugin' ),
'type' => Controls_Manager::TEXT,
]
);
$repeater->add_control(
'icon_note',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => __( 'IMPORTANT! You can use icons class FontAwesome or Flaticon. Examples: <br><br><strong>fas fa-swimmer</strong> - find classes <a href="https://fontawesome.com/v5/search" target="blank">here</a> <br><br><strong>flaticon-laser</strong> - find classes <a href="https://lesya.bslthemes.com/flaticons.html" target="blank">here</a>', 'lesya-plugin' ),
'content_classes' => 'elementor-descriptor',
]
);
$repeater->add_control(
'title', [
'label' => esc_html__( 'Title', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'lesya-plugin' ),
'default' => esc_html__( 'Title', 'lesya-plugin' ),
'dynamic' => [
'active' => true,
],
]
);
$repeater->add_control(
'bg_title', [
'label' => esc_html__( 'BG Title', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'lesya-plugin' ),
'default' => esc_html__( 'Title', 'lesya-plugin' ),
]
);
$repeater->add_control(
'description', [
'label' => esc_html__( 'Description', 'lesya-plugin' ),
'type' => Controls_Manager::WYSIWYG,
'placeholder' => esc_html__( 'Enter description', 'lesya-plugin' ),
'default' => esc_html__( 'Description', 'lesya-plugin' ),
]
);
$repeater->add_control(
'button_show', [
'label' => esc_html__( 'Button', 'lesya-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'lesya-plugin' ),
'label_off' => __( 'Hide', 'lesya-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$repeater->add_control(
'button', [
'label' => esc_html__( 'Button (Text)', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter text', 'lesya-plugin' ),
'default' => esc_html__( 'Button', 'lesya-plugin' ),
'condition' => [
'button_show' => 'yes',
],
'dynamic' => [
'active' => true,
],
]
);
$repeater->add_control(
'link', [
'label' => esc_html__( 'Button (URL)', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::URL,
'show_external' => true,
'condition' => [
'button_show' => 'yes',
],
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'items',
[
'label' => esc_html__( 'Items', 'lesya-plugin' ),
'type' => Controls_Manager::REPEATER,
'prevent_empty' => false,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ title }}}',
]
);
$this->end_controls_section();
$this->start_controls_section(
'shadow_tab',
[
'label' => esc_html__( 'Style', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'shadow_style',
[
'label' => esc_html__( 'Show Shadow Styling', 'lesya-plugin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'lesya-plugin' ),
'label_off' => __( 'Hide', 'lesya-plugin' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$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_icon_color',
[
'label' => esc_html__( 'Icon Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .category-item > i' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'item_title_color',
[
'label' => esc_html__( 'Title Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .category-item .category-title h4' => 'color: {{VALUE}};',
'{{WRAPPER}} .category-item .category-title h4 a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_title_typography',
'label' => esc_html__( 'Title Typography:', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .category-item .category-title h4',
]
);
$this->add_control(
'item_bgtext_color',
[
'label' => esc_html__( 'BG text Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .category-item .category-title .bg-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_bgtext_typography',
'label' => esc_html__( 'BG text Typography:', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .category-item .category-title .bg-text',
]
);
$this->add_control(
'item_text_color',
[
'label' => esc_html__( 'Text Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .category-item .category-title + div' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_text_typography',
'label' => esc_html__( 'Text Typography:', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .category-item .category-title + div',
]
);
$this->add_control(
'item_more_color',
[
'label' => esc_html__( 'More Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .category-item .read-more' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_more_typography',
'label' => esc_html__( 'More Typography:', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .category-item .read-more',
]
);
$this->end_controls_section();
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
?>
<!-- Category Section Start -->
<section class="category-section">
<?php if ( $settings['items'] ) : ?>
<?php $i=2; $j=0; foreach ( $settings['items'] as $index => $item ) : $i+=2; $j++;
$item_title = $this->get_repeater_setting_key( 'title', 'items', $index );
$this->add_inline_editing_attributes( $item_title, 'basic' );
$item_bg_title = $this->get_repeater_setting_key( 'bg_title', 'items', $index );
$this->add_inline_editing_attributes( $item_bg_title, 'none' );
$item_description = $this->get_repeater_setting_key( 'description', 'items', $index );
$this->add_inline_editing_attributes( $item_description, 'advanced' );
$item_button = $this->get_repeater_setting_key( 'button', 'items', $index );
$this->add_inline_editing_attributes( $item_button, 'none' );
?>
<div class="category-item<?php if ( $j%2 != 0 ) : ?> bg-butter<?php else : ?> bg-light-gray<?php endif; ?> wow fadeInUp delay-0-<?php echo esc_attr( $i ); ?>s<?php if ( $settings['shadow_style'] ) : ?> style-two<?php endif; ?>">
<i class="<?php echo esc_attr( $item['icon'] ); ?>"></i>
<div class="category-title">
<?php if ( $item['bg_title'] ) : ?>
<span class="bg-text">
<span <?php echo $this->get_render_attribute_string( $item_bg_title ); ?>>
<?php echo esc_html( $item['bg_title'] ); ?>
</span>
</span>
<?php endif; ?>
<?php if ( $item['title'] ) : ?>
<h4>
<?php if ( $item['link']['url'] ) : ?>
<a<?php if ( $item['link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $item['link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $item['link']['url'] ); ?>">
<?php endif; ?>
<span <?php echo $this->get_render_attribute_string( $item_title ); ?>>
<?php echo wp_kses_post( $item['title'] ); ?>
</span>
<?php if ( $item['link']['url'] ) : ?>
</a>
<?php endif; ?>
</h4>
<?php endif; ?>
</div>
<?php if ( $item['description'] ) : ?>
<div <?php echo $this->get_render_attribute_string( $item_description ); ?>>
<?php echo wp_kses_post( $item['description'] ); ?>
</div>
<?php endif; ?>
<?php if ( $item['button'] ) : ?>
<a<?php if ( $item['link'] ) : ?><?php if ( $item['link']['is_external'] ) : ?> target="_blank"<?php endif; ?><?php if ( $item['link']['nofollow'] ) : ?> rel="nofollow"<?php endif; ?> href="<?php echo esc_url( $item['link']['url'] ); ?>"<?php endif; ?> class="read-more">
<span <?php echo $this->get_render_attribute_string( $item_button ); ?>>
<?php echo esc_html( $item['button'] ); ?>
</span>
<i class="fas fa-long-arrow-alt-right"></i>
</a>
<?php endif; ?>
<div class="for-border"></div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</section>
<!-- Category Section End -->
<?php
}
}
Plugin::instance()->widgets_manager->register_widget_type( new Lesya_Services_Widget() );