File "wgl-rotated-text.php"

Full Path: /home/ubunrgit/public_html/wp-content/plugins/unicoach-core/includes/elementor/widgets/wgl-rotated-text.php
File size: 11.37 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/*
 * This template can be overridden by copying it to yourtheme/unicoach-core/elementor/widgets/wgl-rotated-text.php.
*/
namespace WglAddons\Widgets;

defined('ABSPATH') || exit; // Abort, if called directly.

use Elementor\{Controls_Manager, Group_Control_Typography, Widget_Base};
use WglAddons\Unicoach_Global_Variables as Unicoach_Globals;

class Wgl_Rotated_Text extends Widget_Base
{
    public function get_name()
    {
        return 'wgl-rotated-text';
    }

    public function get_title()
    {
        return esc_html__('WGL Rotated Text', 'unicoach-core');
    }

    public function get_icon()
    {
        return 'wgl-rotated-text';
    }

    public function get_categories()
    {
        return ['wgl-extensions'];
    }

    protected function register_controls()
    {
        /*-----------------------------------------------------------------------------------*/
        /*  CONTENT -> GENERAL
        /*-----------------------------------------------------------------------------------*/

        $this->start_controls_section(
            'wgl_rotated_text_section',
            ['label' => esc_html__('General', 'unicoach-core')]
        );

        $this->add_control(
            'subtitle',
            [
                'label' => esc_html__('Subtitle', 'unicoach-core'),
                'type' => Controls_Manager::TEXT,
                'label_block' => true,
                'dynamic' => ['active' => true],
                'default' => esc_html__('Uunicoach`s Founder', 'unicoach-core'),
            ]
        );

        $this->add_control(
            'rt_title',
            [
                'label' => esc_html__('Title', 'unicoach-core'),
                'type' => Controls_Manager::TEXTAREA,
                'dynamic' => ['active' => true],
                'rows' => 1,
                'placeholder' => esc_attr__('Arnold Black', 'unicoach-core'),
                'default' => esc_html_x('Arnold Black', 'WGL Rotated Text', 'unicoach-core'),
            ]
        );

	    $this->add_responsive_control(
		    'max_height',
		    [
			    'label' => esc_html__('Max Height', 'unicoach-core'),
			    'type' => Controls_Manager::SLIDER,
			    'range' => [
				    'px' => ['min' => 20, 'max' => 1000],
			    ],
			    'default' => ['size' => 240],
			    'selectors' => [
				    '{{WRAPPER}} .wgl-rotated_text' => 'height: {{SIZE}}{{UNIT}};',
			    ],
		    ]
	    );

        $this->add_responsive_control(
            'alignment',
            [
                'label' => esc_html__('Alignment', 'unicoach-core'),
                'type' => Controls_Manager::CHOOSE,
                'toggle' => false,
                'options' => [
                    'left' => [
                        'title' => esc_html__('Left', 'unicoach-core'),
                        'icon' => 'fa fa-align-left',
                    ],
                    'center' => [
                        'title' => esc_html__('Center', 'unicoach-core'),
                        'icon' => 'fa fa-align-center',
                    ],
                    'right' => [
                        'title' => esc_html__('Right', 'unicoach-core'),
                        'icon' => 'fa fa-align-right',
                    ],
                ],
                'default' => 'center',
                'prefix_class' => 'a%s',
            ]
        );

	    $this->add_responsive_control(
		    'disable_rotation',
		    [
			    'label' => esc_html__('Disable Rotation', 'unicoach-core'),
			    'type' => Controls_Manager::SWITCHER,
			    'mobile_default' => 'yes',
			    'return_value' => 'yes',
			    'prefix_class' => 'disable-rotation%s-',
		    ]
	    );

	    $this->add_control(
		    'link',
		    [
			    'label' => esc_html__('Module Link', 'unicoach-core'),
			    'type' => Controls_Manager::URL,
			    'placeholder' => esc_attr__('https://your-link.com', 'unicoach-core'),
		    ]
	    );

        $this->end_controls_section();

        /*-----------------------------------------------------------------------------------*/
        /*  STYLES -> ITEM
        /*-----------------------------------------------------------------------------------*/

        $this->start_controls_section(
            'section_style_item',
            [
                'label' => esc_html__('Item', 'unicoach-core'),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );

	    $this->add_responsive_control(
		    'item_margin',
		    [
			    'label' => esc_html__('Padding', 'unicoach-core'),
			    'type' => Controls_Manager::DIMENSIONS,
			    'size_units' => ['px', 'em', '%'],
			    'default' => [
				    'top' => '25',
				    'right' => '25',
				    'bottom' => '25',
				    'left' => '25',
				    'unit'  => 'px',
				    'isLinked' => false
			    ],
			    'selectors' => [
				    '{{WRAPPER}} .wgl-rotated_text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
			    ],
		    ]
	    );

        $this->end_controls_section();

        /*-----------------------------------------------------------------------------------*/
        /*  STYLES -> TITLE
        /*-----------------------------------------------------------------------------------*/

        $this->start_controls_section(
            'section_style_title',
            [
                'label' => esc_html__('Title', 'unicoach-core'),
                'tab' => Controls_Manager::TAB_STYLE,
                'condition' => ['rt_title!' => ''],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'title_all',
                'selector' => '{{WRAPPER}} .rt__title',
            ]
        );

        $this->add_control(
            'title_tag',
            [
                'label' => esc_html__('HTML Tag', 'unicoach-core'),
                'type' => Controls_Manager::SELECT,
                'options' => [
                    'h1' => '‹h1›',
                    'h2' => '‹h2›',
                    'h3' => '‹h3›',
                    'h4' => '‹h4›',
                    'h5' => '‹h5›',
                    'h6' => '‹h6›',
                    'span' => '‹span›',
                    'div' => '‹div›',
                ],
                'default' => 'h3',
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'title',
                'condition' => ['rt_title!' => ''],
                'selector' => '{{WRAPPER}} .rt__title',
            ]
        );

	    $this->start_controls_tabs(
		    'tabs_title'
	    );

	    $this->start_controls_tab(
		    'tab_title_idle',
		    ['label' => esc_html__('Idle' , 'unicoach-core')]
	    );

	    $this->add_control(
		    'title_color',
		    [
			    'label' => esc_html__('Title Color', 'unicoach-core'),
			    'type' => Controls_Manager::COLOR,
			    'condition' => ['rt_title!' => ''],
			    'dynamic' => ['active' => true],
			    'default' => Unicoach_Globals::get_h_font_color(),
			    'selectors' => [
				    '{{WRAPPER}} .rt__title' => 'color: {{VALUE}};',
			    ],
		    ]
	    );

	    $this->end_controls_tab();

	    $this->start_controls_tab(
		    'title_hover',
		    ['label' => esc_html__('Hover' , 'unicoach-core')]
	    );

	    $this->add_control(
            'title_color_hover',
            [
                'label' => esc_html__('Title Color', 'unicoach-core'),
                'type' => Controls_Manager::COLOR,
                'condition' => ['rt_title!' => ''],
                'dynamic' => ['active' => true],
                'default' => Unicoach_Globals::get_h_font_color(),
                'selectors' => [
                    '{{WRAPPER}} .wgl-rotated_text:hover .rt__title' => 'color: {{VALUE}};',
                ],
            ]
        );

	    $this->end_controls_tab();
	    $this->end_controls_tabs();

        $this->end_controls_section();

        /*-----------------------------------------------------------------------------------*/
        /*  STYLES -> SUBTITLE
        /*-----------------------------------------------------------------------------------*/

        $this->start_controls_section(
            'section_style_subtitle',
            [
                'label' => esc_html__('Subtitle', 'unicoach-core'),
                'tab' => Controls_Manager::TAB_STYLE,
                'condition' => ['subtitle!' => ''],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'subtitle_typo',
                'selector' => '{{WRAPPER}} .rt__subtitle',
            ]
        );

	    $this->add_responsive_control(
		    'subtitle_gap',
		    [
			    'label' => esc_html__('Gap', 'unicoach-core'),
			    'type' => Controls_Manager::SLIDER,
			    'condition' => ['rt_title!' => ''],
			    'range' => [
				    'px' => ['min' => 0, 'max' => 100],
			    ],
			    'default' => ['size' => 11],
			    'render_type' => 'template',
			    'selectors' => [
				    '{{WRAPPER}} .rt__subtitle' => 'margin-right: {{SIZE}}{{UNIT}};',
			    ],
		    ]
	    );

	    $this->start_controls_tabs(
		    'tabs_subtitle'
	    );

	    $this->start_controls_tab(
		    'tab_subtitle_idle',
		    ['label' => esc_html__('Idle' , 'unicoach-core')]
	    );

	    $this->add_control(
		    'subtitle_color',
		    [
			    'label' => esc_html__('Subtitle Color', 'unicoach-core'),
			    'type' => Controls_Manager::COLOR,
			    'dynamic' => ['active' => true],
			    'default' => Unicoach_Globals::get_tertiary_color(),
			    'selectors' => [
				    '{{WRAPPER}} .rt__subtitle' => 'color: {{VALUE}};',
			    ],
		    ]
	    );

	    $this->end_controls_tab();

	    $this->start_controls_tab(
		    'subtitle_hover',
		    ['label' => esc_html__('Hover' , 'unicoach-core')]
	    );

	    $this->add_control(
		    'subtitle_color_hover',
		    [
			    'label' => esc_html__('Subtitle Color', 'unicoach-core'),
			    'type' => Controls_Manager::COLOR,
			    'dynamic' => ['active' => true],
			    'selectors' => [
				    '{{WRAPPER}} .wgl-rotated_text:hover .rt__subtitle' => 'color: {{VALUE}};',
			    ],
		    ]
	    );

	    $this->end_controls_tab();
	    $this->end_controls_tabs();

	    $this->end_controls_section();
    }


	protected function render()
	{
		$_s = $this->get_settings_for_display();

		if (!empty($_s['link']['url'])) {
			$this->add_render_attribute('link', 'class', 'rt__link');
			$this->add_link_attributes('link', $_s['link']);
		}

		$this->add_render_attribute('heading_wrapper', 'class', 'wgl-rotated_text'); ?>
        <div <?php echo $this->get_render_attribute_string('heading_wrapper'); ?>><?php
		if (!empty($_s['link']['url'])) echo '<a ', $this->get_render_attribute_string('link'), '></a>';

		if (!empty($_s['rt_title'])) {
			echo '<', $_s['title_tag'], ' class="rt__title-wrapper">'; ?>
                <span class="rt__title"><?php echo $_s['rt_title']; ?></span><?php
			echo '</', $_s['title_tag'], '>';
		}

		if (!empty($_s['subtitle'])) { ?>
            <div class="rt__subtitle"><?php
			    echo $_s['subtitle']; ?>
            </div><?php
		} ?>
        </div><?php
	}

    public function wpml_support_module() {
        add_filter( 'wpml_elementor_widgets_to_translate',  [$this, 'wpml_widgets_to_translate_filter']);
    }

    public function wpml_widgets_to_translate_filter( $widgets ){
        return \WglAddons\Includes\Wgl_WPML_Settings::get_translate(
            $this, $widgets
        );
    }
}