File: /home/parhudrw/roflma.it/wp-content/plugins/lesya-plugin/elementor/widgets/project-details.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Lesya Project Details Widget.
*
* @since 1.0
*/
class Lesya_Project_Details_Widget extends Widget_Base {
public function get_name() {
return 'lesya-project-details';
}
public function get_title() {
return esc_html__( 'Project Details', '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(
'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 = new \Elementor\Repeater();
$repeater->add_control(
'title', [
'label_block' => true,
'label' => esc_html__( 'Label', 'lesya-plugin' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Enter label', 'lesya-plugin' ),
'placeholder' => esc_html__( 'Label', 'lesya-plugin' ),
]
);
$repeater->add_control(
'text', [
'label_block' => true,
'label' => esc_html__( 'Value', 'lesya-plugin' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Enter value', 'lesya-plugin' ),
'placeholder' => esc_html__( 'Value', 'lesya-plugin' ),
]
);
$this->add_control(
'items',
[
'label' => esc_html__( 'Details', 'lesya-plugin' ),
'type' => Controls_Manager::REPEATER,
'prevent_empty' => false,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ title }}}',
]
);
$this->end_controls_section();
$this->start_controls_section(
'content_styling',
[
'label' => esc_html__( 'Content', 'lesya-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'item_label_color',
[
'label' => esc_html__( 'Details Label Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .portfolio-details-list li h5' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_label_typography',
'label' => esc_html__( 'Label Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .portfolio-details-list li h5',
]
);
$this->add_control(
'item_value_color',
[
'label' => esc_html__( 'Value Color', 'lesya-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .portfolio-details-list li .text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'item_value_typography',
'label' => esc_html__( 'Value Typography', 'lesya-plugin' ),
'selector' => '{{WRAPPER}} .portfolio-details-list li .text',
]
);
$this->end_controls_section();
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
?>
<div class="portfolio-details-list">
<?php if ( $settings['items'] ) : ?>
<ul>
<?php foreach ( $settings['items'] as $index => $item ) :
$item_title = $this->get_repeater_setting_key( 'title', 'items', $index );
$this->add_inline_editing_attributes( $item_title, 'basic' );
$item_text = $this->get_repeater_setting_key( 'text', 'items', $index );
$this->add_inline_editing_attributes( $item_text, 'basic' );
?>
<li>
<?php if ( $item['title'] ) : ?>
<h5>
<span <?php echo $this->get_render_attribute_string( $item_title ); ?>>
<?php echo wp_kses_post( $item['title'] ); ?>
</span>
</h5>
<span class="symbol">:</span>
<?php endif; ?>
<?php if ( $item['text'] ) : ?>
<span class="text">
<span <?php echo $this->get_render_attribute_string( $item_text ); ?>>
<?php echo wp_kses_post( $item['text'] ); ?>
</span>
</span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<?php
}
}
Plugin::instance()->widgets_manager->register_widget_type( new Lesya_Project_Details_Widget() );