<?php
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
use Elementor\Group_Control_Box_Shadow;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Image_Size;
use Elementor\Group_Control_Border;
use Elementor\Icons_Manager;
use Motiox\Elementor\Motiox_Base_Widgets;
use Elementor\Utils;
class Motiox_Elementor_Move_Cursor extends Motiox_Base_Widgets {
/**
* Get widget name.
*
* Retrieve testimonial widget name.
*
* @return string Widget name.
* @since 1.0.0
* @access public
*
*/
public function get_name() {
return 'motiox-move-cursor';
}
/**
* Get widget title.
*
* Retrieve testimonial widget title.
*
* @return string Widget title.
* @since 1.0.0
* @access public
*
*/
public function get_title() {
return esc_html__('Motiox Move Cursor', 'motiox');
}
/**
* Get widget icon.
*
* Retrieve testimonial widget icon.
*
* @return string Widget icon.
* @since 1.0.0
* @access public
*
*/
public function get_icon() {
return 'eicon-testimonial';
}
public function get_script_depends() {
return ['motiox-elementor-move-cursor'];
}
public function get_categories() {
return array('motiox-addons');
}
/**
* Register testimonial widget controls.
*
* Adds different input fields to allow the user to change and customize the widget settings.
*
* @since 1.0.0
* @access protected
*/
protected function register_controls() {
$this->start_controls_section(
'section_move_cursor',
[
'label' => esc_html__('Move Cursor', 'motiox'),
]
);
$this->add_control(
'icon_select',
[
'label' => esc_html__('Icon select', 'motiox'),
'type' => Controls_Manager::SELECT,
'default' => 'use_icon',
'options' => [
'use_icon' => esc_html__('Use Icon', 'motiox'),
'use_title_cursor' => esc_html__('Use Title', 'motiox'),
],
]
);
$this->add_control(
'selected_icon',
[
'label' => esc_html__('Icon', 'motiox'),
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'icon',
'default' => [
'value' => 'fas fa-star',
'library' => 'fa-solid',
],
'condition' => [
'icon_select' => 'use_icon',
],
]
);
$this->add_control(
'title_cursor',
[
'label' => esc_html__('Title Cursor', 'motiox'),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'placeholder' => esc_html__('Enter your title', 'motiox'),
'label_block' => true,
'condition' => [
'icon_select' => 'use_title_cursor',
],
]
);
$this->add_control(
'title_move',
[
'label' => esc_html__('Title Move', 'motiox'),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'placeholder' => esc_html__('Enter your title', 'motiox'),
'label_block' => true,
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_style_move_cursor',
[
'label' => esc_html__('Cursor', 'motiox'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'move_cursor_alignment',
[
'label' => esc_html__('Alignment Content', 'motiox'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__('Left', 'motiox'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__('Center', 'motiox'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__('Right', 'motiox'),
'icon' => 'eicon-text-align-right',
],
],
'label_block' => false,
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper' => 'text-align: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'padding_content_inner',
[
'label' => esc_html__('Padding', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'margin_move_cursor',
[
'label' => esc_html__('Margin', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_style_icon_move',
[
'label' => esc_html__('Icon', 'motiox'),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'icon_select' => 'use_icon',
]
]
);
$this->add_control(
'icon_move_color',
[
'label' => esc_html__('Color', 'motiox'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper .icon-title-move .elementor-icon-box-icon .elementor-move-icon' => 'color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'icon_move_size_inner',
[
'label' => esc_html__('Size', 'motiox'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper .icon-title-move .elementor-icon-box-icon .elementor-move-icon i' => 'font-size: {{SIZE}}{{UNIT}}',
],
]
);
$this->add_responsive_control(
'icon_move_width',
[
'label' => esc_html__('Width', 'motiox'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 10,
'max' => 500,
],
'vw' => [
'min' => 1,
'max' => 100,
],
],
'size_units' => ['px', '%', 'vw'],
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper .icon-title-move .elementor-icon-box-icon' => 'width: {{SIZE}}{{UNIT}}',
],
]
);
$this->add_responsive_control(
'icon_move_height',
[
'label' => esc_html__('Height', 'motiox'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 10,
'max' => 500,
],
'vh' => [
'min' => 10,
'max' => 100,
],
],
'size_units' => ['px', 'vh', '%'],
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper .icon-title-move .elementor-icon-box-icon' => 'height: {{SIZE}}{{UNIT}}',
],
]
);
$this->add_control(
'icon_move_radius',
[
'label' => esc_html__('Border Radius', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper .icon-title-move .elementor-icon-box-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_style_title_cursor',
[
'label' => esc_html__('Title Cursor', 'motiox'),
'tab' => Controls_Manager::TAB_STYLE,
'condition' => [
'icon_select' => 'use_title_cursor',
]
]
);
$this->add_control(
'title_cursor_color',
[
'label' => esc_html__('Color', 'motiox'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper .icon-title-move .title-cursor .title' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_cursor_typography',
'selector' => '{{WRAPPER}} .elementor-move-cursor-wrapper .icon-title-move .title-cursor .title',
]
);
$this->add_responsive_control(
'title_cursor_width',
[
'label' => esc_html__('Width', 'motiox'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 10,
'max' => 500,
],
'vw' => [
'min' => 1,
'max' => 100,
],
],
'size_units' => ['px', '%', 'vw'],
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper .icon-title-move .title-cursor' => 'width: {{SIZE}}{{UNIT}}',
],
]
);
$this->add_responsive_control(
'title_cursor_height',
[
'label' => esc_html__('Height', 'motiox'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 10,
'max' => 500,
],
'vh' => [
'min' => 10,
'max' => 100,
],
],
'size_units' => ['px', 'vh', '%'],
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper .icon-title-move .title-cursor' => 'height: {{SIZE}}{{UNIT}}',
],
]
);
$this->add_control(
'title_cursor_radius',
[
'label' => esc_html__('Border Radius', 'motiox'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper .icon-title-move .title-cursor' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_style_title_move',
[
'label' => esc_html__('Title Move', 'motiox'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_move_color',
[
'label' => esc_html__('Color', 'motiox'),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-move-cursor-wrapper .title-move' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_move_typography',
'selector' => '{{WRAPPER}} .elementor-move-cursor-wrapper .title-move',
]
);
$this->add_control(
'title_move_gradient_effects',
[
'label' => esc_html__('Color Gradient', 'motiox'),
'type' => Controls_Manager::SWITCHER,
'prefix_class' => 'enable-effects-gradient-',
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$this->add_render_attribute( 'icon', 'class', [ 'elementor-move-icon' ] );
if ( ! isset( $settings['icon'] ) && ! Icons_Manager::is_migration_allowed() ) {
// add old default
$settings['icon'] = 'fa fa-star';
}
$icon_tag = 'span';
$has_icon = ! empty( $settings['icon'] );
if ( $has_icon ) {
$this->add_render_attribute( 'i', 'class', $settings['icon'] );
$this->add_render_attribute( 'i', 'aria-hidden', 'true' );
}
if ( ! $has_icon && ! empty( $settings['selected_icon']['value'] ) ) {
$has_icon = true;
}
$migrated = isset( $settings['__fa4_migrated']['selected_icon'] );
$is_new = ! isset( $settings['icon'] ) && Icons_Manager::is_migration_allowed();
?>
<div class="elementor-move-cursor-wrapper cursor-move">
<div class="icon-title-move">
<?php if ( $has_icon ) : ?>
<div class="elementor-icon-box-icon">
<<?php Utils::print_validated_html_tag( $icon_tag ); ?> <?php $this->print_render_attribute_string( 'icon' ); ?> <?php $this->print_render_attribute_string( 'link' ); ?>>
<?php
if ( $is_new || $migrated ) {
Icons_Manager::render_icon( $settings['selected_icon'], [ 'aria-hidden' => 'true' ] );
} elseif ( ! empty( $settings['icon'] ) ) {
?><i <?php $this->print_render_attribute_string( 'i' ); ?>></i><?php
}
?>
</<?php Utils::print_validated_html_tag( $icon_tag ); ?>>
</div>
<?php endif; ?>
<?php if (!empty($settings['title_cursor'])) : ?>
<div class="title-cursor">
<div class="title">
<?php echo sprintf('%s', $settings['title_cursor']); ?>
</div>
</div>
<?php endif; ?>
</div>
<?php if (!empty($settings['title_move'])) : ?>
<div class="title-move"><?php echo sprintf('%s', $settings['title_move']); ?></div>
<?php endif; ?>
</div>
<?php
}
}
$widgets_manager->register(new Motiox_Elementor_Move_Cursor());