GhostManSec
Server: LiteSpeed
System: Linux premium197.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: parhudrw (1725)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/parhudrw/roflma.it/wp-content/plugins/lesya-plugin/elementor/widgets/services-popular.php
<?php
namespace Elementor;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
 * Lesya Services Popular Widget.
 *
 * @since 1.0
 */

class Lesya_Services_Popular_Widget extends Widget_Base {

	public function get_name() {
		return 'lesya-services-popular';
	}

	public function get_title() {
		return esc_html__( 'Services Popular', '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(
			'heading_tab',
			[
				'label' => esc_html__( 'Heading', 'lesya-plugin' ),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
		);

		$this->add_control(
			'heading',
			[
				'label' => esc_html__( 'Heading', 'lesya-plugin' ),
				'type' => Controls_Manager::SWITCHER,
				'label_on' => __( 'Show', 'lesya-plugin' ),
				'label_off' => __( 'Hide', 'lesya-plugin' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);

		$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' ),
			]
		);

		$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' ),
			]
		);

		$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(),
				],
			]
		);

		$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-shape1',
			[
				'label'       => esc_html__( 'Image Shape #1', 'lesya-plugin' ),
				'type'        => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],
				'condition' => [
		      'shapes_show' => 'yes'
		    ],
			]
		);

		$this->add_control(
			'image-shape2',
			[
				'label'       => esc_html__( 'Image Shape #2', 'lesya-plugin' ),
				'type'        => Controls_Manager::MEDIA,
				'default' => [
					'url' => Utils::get_placeholder_image_src(),
				],
				'condition' => [
		      'shapes_show' => 'yes'
		    ],
			]
		);

		$this->add_control(
			'image-shape3',
			[
				'label'       => esc_html__( 'Image Shape 3', '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(
			'items_tab',
			[
				'label' => esc_html__( 'Items', 'lesya-plugin' ),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
		);

		$repeater = new \Elementor\Repeater();

		$repeater->add_control(
			'image', [
				'label' => esc_html__( 'Image', 'lesya-plugin' ),
				'type' => Controls_Manager::MEDIA,
				'default' => [
					'url' => \Elementor\Utils::get_placeholder_image_src(),
				],
			]
		);

		$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(
			'link', [
				'label'       => esc_html__( 'Button (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' => '{{{ title }}}',
			]
		);

		$this->end_controls_section();

		$this->start_controls_section(
			'buttons_tab',
			[
				'label' => esc_html__( 'Buttons', 'lesya-plugin' ),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
		);

		$this->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',
			]
		);

		$this->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,
				],
			]
		);

		$this->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->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->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}} .popular-service-item i' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_control(
			'item_title_color',
			[
				'label' => esc_html__( 'Title Color', 'lesya-plugin' ),
				'type' => Controls_Manager::COLOR,
				'default'   => '',
				'selectors' => [
					'{{WRAPPER}} .popular-service-item h5' => 'color: {{VALUE}};',
				],
			]
		);

		$this->add_group_control(
			Group_Control_Typography::get_type(),
			[
				'name' => 'item_title_typography',
				'label' => esc_html__( 'Title Typography:', 'lesya-plugin' ),
				'selector' => '{{WRAPPER}} .popular-service-item h5',
			]
		);

		$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( 'button', 'none' );

		?>

		<!-- Popular Services Start -->
		<section class="popular-services rel z-1 py-150 rpy-100">
				<div class="container">
						<div class="row align-items-center">
								<div class="col-lg-6">
										<?php if ( $settings['image'] ) : $image = wp_get_attachment_image_url( $settings['image']['id'], 'lesya_1920xAuto' ); ?>
										<div class="service-left rmb-55 wow fadeInLeft delay-0-2s">
												<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr__( 'image', 'lesya-plugin' ); ?>" />
										</div>
										<?php endif; ?>
								</div>
								<div class="col-lg-6">
										<div class="popular-service-wrap wow fadeInRight delay-0-2s">
												<?php if ( $settings['heading'] == 'yes' && $settings['subtitle'] && $settings['title'] ) : ?>
												<div class="section-title mb-50">
														<?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['items'] ) : ?>
												<div class="row">
														<?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' );
														?>
														<div class="col-xl-4 col-lg-6 col-sm-4 col-6 col-small">
																<a class="popular-service-item"<?php if ( $item['link']['url'] ) : ?><?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; ?>>
																		<?php if ( $item['icon'] ) : ?>
																		<i class="<?php echo esc_attr( $item['icon'] ); ?>"></i>
																		<?php endif; ?>
																		<?php if ( $item['title'] ) : ?>
																		<h5>
																			<span <?php echo $this->get_render_attribute_string( $item_title ); ?>>
																				<?php echo wp_kses_post( $item['title'] ); ?>
																			</span>
																		</h5>
																		<?php endif; ?>
																</a>
														</div>
														<?php endforeach; ?>
												</div>
												<?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 mt-30">
													<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['image-shape1'] ) : $image = wp_get_attachment_image_url( $settings['image-shape1']['id'], 'lesya_900xAuto' ); ?>
				<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr__( 'Shape', 'lesya-plugin' ); ?>" class="white-leaf" />
				<?php endif; ?>
				<?php if ( $settings['image-shape2'] ) : $image = wp_get_attachment_image_url( $settings['image-shape2']['id'], 'lesya_900xAuto' ); ?>
				<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr__( 'Shape', 'lesya-plugin' ); ?>" class="color-leaf" />
				<?php endif; ?>
				<?php if ( $settings['image-shape3'] ) : $image = wp_get_attachment_image_url( $settings['image-shape3']['id'], 'lesya_900xAuto' ); ?>
				<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr__( 'Shape', 'lesya-plugin' ); ?>" class="circle" />
				<?php endif; ?>
		</section>
		<!-- Popular Services End -->

		<?php
	}
}

Plugin::instance()->widgets_manager->register_widget_type( new Lesya_Services_Popular_Widget() );