File "cta-area.php"

Full Path: /home/flipjqml/onlinebetsolution.com/wp-content/plugins/cyarb-toolkit/widgets/cta-area.php
File size: 17.55 KB
MIME-type: text/x-php
Charset: utf-8

<?php
namespace Elementor;
class CTAWidget extends Widget_Base{
    public function get_name(){
        return "CTA-widget";
    }
    public function get_title(){
        return "CTA Area";
    }
    public function get_icon(){
        return "eicon-info-box";
    }
    public function get_categories(){
        return ['cyarb-elements'];
    }

    protected function register_controls(){
        // Tab content controls
        $this-> start_controls_section(
            'section_content',
            [
                'label' => __('Content', 'cyarb-toolkit'),
                'tab'   => Controls_Manager::TAB_CONTENT,
            ]
        );

        $this->add_control(
            'choose_style',
            [
                'label'   => __( 'Choose Style', 'cyarb-toolkit' ),
                'type'    => Controls_Manager::SELECT,
                'options' => [
                    '1'         => __( 'Style One', 'cyarb-toolkit' ),
                    '2'         => __( 'Style Two', 'cyarb-toolkit' ),
                ],
                'default' => '1',
            ]
        );
        
        $this->add_control(
            'title', [
                'label'       => __( 'Add Title', 'cyarb-toolkit' ),
                'type'        => Controls_Manager:: TEXTAREA,
                'label_block' => true,
            ]
        );

        $this->add_control(
            'title_tag',
            [
                'label'   => esc_html__( 'Title Tag', 'cyarb-toolkit' ),
                'type'    => Controls_Manager::SELECT,
                'options' => [
                    'h1'         => esc_html__( 'h1', 'cyarb-toolkit' ),
                    'h2'         => esc_html__( 'h2', 'cyarb-toolkit' ),
                    'h3'         => esc_html__( 'h3', 'cyarb-toolkit' ),
                    'h4'         => esc_html__( 'h4', 'cyarb-toolkit' ),
                    'h5'         => esc_html__( 'h5', 'cyarb-toolkit' ),
                    'h6'         => esc_html__( 'h6', 'cyarb-toolkit' ),
                ],
                'default' => 'h2',
            ]
        );

        $this->add_control(
            'button_text',
            [
                'label'   => __( 'Button Text', 'cyarb-toolkit' ),
                'type'    => Controls_Manager::TEXT,
                'default' => __('Get A Free Quote', 'cyarb-toolkit'),
            ]
        );

		$this->add_control(
            'link_type',
            [
                'label'       => __( 'Link Type', 'cyarb-toolkit' ),
                'type'        => Controls_Manager::SELECT,
                'label_block' => true,
                'options' => [
                    '1'  => __( 'Link To Page', 'cyarb-toolkit' ),
                    '2'  => __( 'External Link', 'cyarb-toolkit' ),
                ], 
            ]
        );

        $this->add_control(
            'link_to_page',
            [
                'label'       => __( 'Link Page', 'cyarb-toolkit' ),
                'type'        => Controls_Manager::SELECT,
                'label_block' => true,
                'options'      => cyarb_toolkit_get_page_as_list(),
                'condition' => [
                    'link_type' => '1',
                ]
            ]
        );

        $this->add_control(
            'external_link',
            [
                'label'     =>__('External Link', 'cyarb-toolkit'),
                'type'      => Controls_Manager:: TEXT,
                'condition' => [
                    'link_type' => '2',
                ]
            ]
        );

        //Target Page
        $this->add_control(
			'target_page',
			[
				'label'    => __( 'Link Open In New Tab?', 'cyarb-toolkit' ),
				'type'     => Controls_Manager::SWITCHER,
				'label_on' => __( 'Yes', 'cyarb-toolkit' ),
				'label_off'    => __( 'No', 'cyarb-toolkit' ),
				'return_value' => 'yes',
                'default'      => 'yes',
			]
		);
        $this-> end_controls_section();

        $this->start_controls_section(
			'section_images',
			[
				'label' => esc_html__( 'Images', 'cyarb-toolkit' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			]
        );
            $this->add_control(
                'fimage',
                [
                    'label'     => esc_html__( 'Add Background Image', 'cyarb-toolkit' ),
                    'type'	    => Controls_Manager::MEDIA,
                    'condition' => [
                        'choose_style' => '1',
                    ]
                ]
            );

            //Shape Images
            $this->add_control(
                'image_shape',
                [
                    'label' => esc_html__( 'Hide Shapes?', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::SWITCHER,
                    'label_on' => esc_html__( 'Show', 'cyarb-toolkit' ),
                    'label_off' => esc_html__( 'Hide', 'cyarb-toolkit' ),
                    'return_value' => 'yes',
                    'default' => 'yes',
                ]
            );
            $this->add_control(
                'shape1',
                [
                    'label' => esc_html__( 'Add Shape', 'cyarb-toolkit' ),
                    'type'	 => Controls_Manager::MEDIA,
                    'condition' => [
                        'image_shape' => 'yes',
                    ]
                ]
            );
            $this->add_control(
                'shape2',
                [
                    'label' => esc_html__( 'Add Shape 2', 'cyarb-toolkit' ),
                    'type'	 => Controls_Manager::MEDIA,
                    'condition' => [
                        'image_shape' => 'yes',
                    ]
                ]
            );
        $this->end_controls_section();

        // End Tab content controls

        // Start Style content controls
        $this-> start_controls_section(
            'content_style',
            [
                'label' =>__('Content', 'cyarb-toolkit'),
                'tab'   => Controls_Manager::TAB_STYLE,
            ]
        );
            $this->add_control(
                'section_bg_color',
                [
                    'label'     => __( 'Section Background Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .cta-inner' => 'background-color: {{VALUE}}',
                    ],
                    'condition' => [
                        'choose_style' => '1',
                    ]
                ]
            );

            $this->add_control(
                'sec_head',
                [
                    'label'     => esc_html__( 'Section Background Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::HEADING,
                    'separator' => 'before',
                    'condition' => [
                        'choose_style' => '2',
                    ]
                ]
            );
            $this->add_group_control(
                Group_Control_Background::get_type(),
                [
                    'name'     => 'section_bg2_color',
                    'types'    => ['gradient' ],
                    'selector' => '{{WRAPPER}} .cta-style-two-area',
                    'condition' => [
                        'choose_style' => '2',
                    ]
                ]
            );
            $this->add_control(
				'onedivider',
				[
					'type' => Controls_Manager::DIVIDER,
				]
			);
            $this->add_control(
				'twodivider',
				[
					'type' => Controls_Manager::DIVIDER,
				]
			);
            $this->add_control(
                'title_color',
                [
                    'label'     => __( 'Title Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .cta-inner h1, .cta-inner h2, .cta-inner h3, .cta-inner h4, .cta-inner h5, .cta-inner h6, .cta-inner-box-content h2, .cta-inner-box-content h1, .cta-inner-box-content h3, .cta-inner-box-content h4, .cta-inner-box-content h5, .cta-inner-box-content h6' => 'color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name'     => 'title_type_typography',
                    'label'    => __( 'Title Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .cta-inner h1, .cta-inner h2, .cta-inner h3, .cta-inner h4, .cta-inner h5, .cta-inner h6, .cta-inner-box-content h2, .cta-inner-box-content h1, .cta-inner-box-content h3, .cta-inner-box-content h4, .cta-inner-box-content h5, .cta-inner-box-content h6',
                ]
            );

            $this->add_control(
                'btn_color',
                [
                    'label'     => __( 'Button Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .cta-inner .default-btn, .default-btn-two' => 'color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'btn_bgcolor',
                [
                    'label'     => __( 'Button Background Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .cta-inner .default-btn' => 'background-color: {{VALUE}}',
                    ],
                    'condition' => [
                        'choose_style' => '1',
                    ]
                ]
            );
            $this->add_control(
                'btn_bg_head',
                [
                    'label'     => esc_html__( 'Button Background Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::HEADING,
                    'separator' => 'before',
                    'condition' => [
                        'choose_style' => '2',
                    ]
                ]
            );
            $this->add_group_control(
                Group_Control_Background::get_type(),
                [
                    'name'     => 'btn_bg2_color',
                    'types'    => ['gradient' ],
                    'selector' => '{{WRAPPER}} .cta-inner-box-content .default-btn-two',
                    'condition' => [
                        'choose_style' => '2',
                    ]
                ]
            );
            $this->add_control(
				'threedivider',
				[
					'type' => Controls_Manager::DIVIDER,
				]
			);
            $this->add_control(
				'fourdivider',
				[
					'type' => Controls_Manager::DIVIDER,
				]
			);
            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name'     => 'btn_type_typography',
                    'label'    => __( 'Button Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .cta-inner .default-btn, .default-btn-two',
                ]
            );
            $this->add_control(
                'btn_hcolor',
                [
                    'label'     => __( 'Button Hover Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .cta-inner .default-btn:hover, .default-btn-two:hover' => 'color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'btn_hbgcolor',
                [
                    'label'     => __( 'Button Background Hover Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .cta-inner .default-btn:hover, .default-btn span::before, .default-btn span::after, .default-btn:hover::before, .default-btn:hover::after' => 'background-color: {{VALUE}}',
                    ],
                    'condition' => [
                        'choose_style' => '1',
                    ]
                ]
            );

            $this->add_control(
                'btn_hbg_head',
                [
                    'label'     => esc_html__( 'Button Hover Background Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::HEADING,
                    'separator' => 'before',
                    'condition' => [
                        'choose_style' => '2',
                    ]
                ]
            );
            $this->add_group_control(
                Group_Control_Background::get_type(),
                [
                    'name'     => 'btn_hbg2_color',
                    'types'    => ['gradient' ],
                    'selector' => '{{WRAPPER}} .default-btn-two::before',
                    'condition' => [
                        'choose_style' => '2',
                    ]
                ]
            );
        $this-> end_controls_section();
    }

    protected function render()
    {
        // Retrieve all controls value
        $settings = $this->get_settings_for_display();

        $btn1_text  = $settings['button_text'];

        //  Button Link
        $link_source = '';

        if( $settings['link_type'] == 1 ){
            $link_source = get_page_link($settings['link_to_page']); 
        } else {
            $link_source = $settings['external_link'];
        } ?>

        <?php if( $settings['choose_style'] == '1' ): ?>
            <div class="cta-area pb-100">
                <div class="container">
                    <div class="cta-inner" style="background-image:url(<?php echo esc_url( $settings['fimage']['url'] ); ?>);">
                        <<?php echo esc_attr( $settings['title_tag'] ); ?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr( $settings['title_tag'] ); ?>>

                        <?php if($btn1_text != '') { 
                            if ( 'yes' === $settings['target_page'] ) { ?>
                                <a target="_blank" href="<?php echo esc_url($link_source); ?>" class="default-btn">
                                    <span><?php echo esc_html($btn1_text); ?></span>
                                </a>
                            <?php } else { ?>
                                <a href="<?php echo esc_url($link_source); ?>" class="default-btn">
                                    <span><?php echo esc_html($btn1_text); ?></span>
                                </a>
                            <?php }  
                        } ?>
                        <?php if ( 'yes' === $settings['image_shape'] ) : ?>
                            <?php if( $settings['shape1']['url'] != '' ) : ?>
                                <div class="shape9"><img src="<?php echo esc_url( $settings['shape1']['url'] ); ?>" alt="<?php echo esc_attr__( 'Shape', 'cyarb-toolkit' ); ?>"></div>
                            <?php endif; ?>
                            <?php if( $settings['shape2']['url'] != '' ) : ?>
                                <div class="shape10"><img src="<?php echo esc_url( $settings['shape2']['url'] ); ?>" alt="<?php echo esc_attr__( 'Shape2', 'cyarb-toolkit' ); ?>"></div>
                            <?php endif; ?>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        <?php else: ?>
            <div class="cta-style-two-area ptb-100">
                <div class="container">
                    <div class="cta-inner-box-content">
                        <<?php echo esc_attr( $settings['title_tag'] ); ?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr( $settings['title_tag'] ); ?>>

                        <?php if($btn1_text != '') { 
                            if ( 'yes' === $settings['target_page'] ) { ?>
                                <a target="_blank" href="<?php echo esc_url($link_source); ?>" class="default-btn-two">
                                    <span><?php echo esc_html($btn1_text); ?></span>
                                </a>
                            <?php } else { ?>
                                <a href="<?php echo esc_url($link_source); ?>" class="default-btn-two">
                                    <span><?php echo esc_html($btn1_text); ?></span>
                                </a>
                            <?php }  
                        } ?>
                        <?php if ( 'yes' === $settings['image_shape'] ) : ?>
                            <?php if( $settings['shape1']['url'] != '' ) : ?>
                                <div class="shape9"><img src="<?php echo esc_url( $settings['shape1']['url'] ); ?>" alt="<?php echo esc_attr__( 'Shape', 'cyarb-toolkit' ); ?>"></div>
                            <?php endif; ?>
                            <?php if( $settings['shape2']['url'] != '' ) : ?>
                                <div class="shape10"><img src="<?php echo esc_url( $settings['shape2']['url'] ); ?>" alt="<?php echo esc_attr__( 'Shape2', 'cyarb-toolkit' ); ?>"></div>
                            <?php endif; ?>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        <?php endif; ?>
        <?php
    }
}
Plugin::instance()->widgets_manager->register_widget_type( new CTAWidget );