File: //home/parhudrw/roflma.it/wp-content/plugins/lesya-plugin/elementor/widgets/header-contacts.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Lesya Header Contacts Widget.
*
* @since 1.0
*/
class Lesya_Header_Contacts_Widget extends Widget_Base {
public function get_name() {
return 'lesya-header-contacts';
}
public function get_title() {
return esc_html__( 'Header Contacts', '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' ),
'label_block' => true,
'type' => Controls_Manager::ICONS,
]
);
$repeater->add_control(
'label', [
'label' => esc_html__( 'Label', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter label', 'lesya-plugin' ),
'default' => esc_html__( 'Label', 'lesya-plugin' ),
]
);
$repeater->add_control(
'text', [
'label' => esc_html__( 'Text', 'lesya-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter text', 'lesya-plugin' ),
'default' => esc_html__( 'Text', 'lesya-plugin' ),
]
);
$repeater->add_control(
'link', [
'label' => esc_html__( 'URL', 'lesya-plugin' ),
'label_block' => true,
'type' => Controls_Manager::URL,
'show_external' => true,
'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' => '{{{ label }}}',
]
);
$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}} .header-top ul li i' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'item_label_color',
[
'label' => esc_html__( 'Label Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .header-top ul li span' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_label_typography',
'label' => esc_html__( 'Label Typography:', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .header-top ul li span',
]
);
$this->add_control(
'item_text_color',
[
'label' => esc_html__( 'Text Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .header-top ul li 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}} .header-top ul li div',
]
);
$this->end_controls_section();
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
?>
<?php if ( $settings['items'] ) : ?>
<div class="header-top">
<ul>
<?php foreach ( $settings['items'] as $index => $item ) :
$item_label = $this->get_repeater_setting_key( 'label', 'items', $index );
$this->add_inline_editing_attributes( $item_label, 'basic' );
$item_text = $this->get_repeater_setting_key( 'text', 'items', $index );
$this->add_inline_editing_attributes( $item_text, 'basic' );
?>
<li>
<?php if ( $item['icon'] ) : ?>
<?php \Elementor\Icons_Manager::render_icon( $item['icon'], [ 'aria-hidden' => 'true' ] ); ?>
<?php endif; ?>
<?php if ( $item['label'] ) : ?>
<span <?php echo $this->get_render_attribute_string( $item_label ); ?>>
<?php echo wp_kses_post( $item['label'] ); ?>
</span>
<?php endif; ?>
<?php if ( $item['text'] ) : ?>
<div <?php echo $this->get_render_attribute_string( $item_text ); ?>>
<?php echo wp_kses_post( $item['text'] ); ?>
</div>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php
}
}
Plugin::instance()->widgets_manager->register_widget_type( new Lesya_Header_Contacts_Widget() );