File "banner-four.php"

Full Path: /home/flipjqml/onlinebetsolution.com/next_old/wp-content/plugins/cyarb-toolkit/widgets/banner-four.php
File size: 16.11 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/**
 * Banner Four Widget
 */

namespace Elementor;
class Cyarb_Banner_Four extends Widget_Base {

	public function get_name() {
        return 'Cyarb_BannerFour';
    }

	public function get_title() {
        return __( 'Banner Four', 'cyarb-toolkit' );
    }

	public function get_icon() {
        return 'eicon-banner';
    }

	public function get_categories() {
        return [ 'cyarb-elements' ];
    }

	protected function register_controls() {

        $this->start_controls_section(
			'Cyarb_Banner_Area',
			[
				'label' => __( 'Banner Four', 'cyarb-toolkit' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			]
		);

        $this->add_control(
            'title_type',
            [
                'label'       => __( 'Choose Heading Type', 'cyarb-toolkit' ),
                'type'        => Controls_Manager::SELECT,
                'label_block' => true,
                'options'     => [
                    'h1' => __( 'h1', 'cyarb-toolkit' ),
                    'h2' => __( 'h2', 'cyarb-toolkit' ),
                    'h3' => __( 'h3', 'cyarb-toolkit' ),
                    'h4' => __( 'h4', 'cyarb-toolkit' ),
                    'h5' => __( 'h5', 'cyarb-toolkit' ),
                    'h6' => __( 'h6', 'cyarb-toolkit' ),
                ], 
                'default' => 'h1'
            ]
        );

        $repeater = new Repeater();
        $repeater->add_control(
            'banner_title', [
                'label' => __( 'Add Banner Title', 'cyarb-toolkit' ),
                'type'  => Controls_Manager:: TEXTAREA,
            ]
		);
        $repeater->add_control(
            'banner_desc',
            [
                'label'       =>__('Banner Description', 'cyarb-toolkit'),
                'type'        => Controls_Manager:: WYSIWYG,
                'description' => __('This text editor for p','cyarb-toolkit'),
            ]
		);
        $repeater->add_control(
            'add_image',
            [
                'label' => __('Add Banner Image', 'cyarb-toolkit' ),
                'type'  => Controls_Manager::MEDIA,
                'default' => [
                    'url' => Utils::get_placeholder_image_src(),
                ]
            ]
        );
        $repeater->add_control(
            'btn_text1',
            [
                'label' => esc_html__('Button One Title', 'cyarb-toolkit'),
                'type'  => Controls_Manager:: TEXT,
            ]
        );
        $repeater->add_control(
            'link_type',
            [
                'label' => esc_html__( 'Link Type', 'cyarb-toolkit' ),
                'type'  => Controls_Manager::SELECT,
                'label_block' => true,
                'options' => [
                    '1'  => esc_html__( 'Link To Page', 'cyarb-toolkit' ),
                    '2'  => esc_html__( 'External Link', 'cyarb-toolkit' ),
                ],
            ]
        );
        $repeater->add_control(
            'link_to_page',
            [
                'label'       => esc_html__( 'Link Page', 'cyarb-toolkit' ),
                'type'        => Controls_Manager::SELECT,
                'label_block' => true,
                'options'     => cyarb_toolkit_get_page_as_list(),
                'condition'   => [
                    'link_type' => '1',
                ]
            ]
        );
        $repeater->add_control(
            'external_link',
            [
                'label'     => esc_html__('External Link', 'cyarb-toolkit'),
                'type'      => Controls_Manager:: TEXT,
                'condition' => [
                    'link_type' => '2',
                ]
            ]
        );
        // Button Two
        $repeater->add_control(
            'btn_text2',
            [
                'label' => esc_html__('Button Two Title', 'cyarb-toolkit'),
                'type'  => Controls_Manager:: TEXT,
            ]
        );
        $repeater->add_control(
            'link_type2',
            [
                'label' => esc_html__( 'Link Type 2', 'cyarb-toolkit' ),
                'type'  => Controls_Manager::SELECT,
                'label_block' => true,
                'options' => [
                    '1'  => esc_html__( 'Link To Page', 'cyarb-toolkit' ),
                    '2' => esc_html__( 'External Link', 'cyarb-toolkit' ),
                ],
            ]
        );
        $repeater->add_control(
            'link_to_page2',
            [
                'label'       => esc_html__( 'Link Page', 'cyarb-toolkit' ),
                'type'        => Controls_Manager::SELECT,
                'label_block' => true,
                'options'     => cyarb_toolkit_get_page_as_list(),
                'condition'   => [
                    'link_type2' => '1',
                ]
            ]
        );
        $repeater->add_control(
            'external_link2',
            [
                'label'     => esc_html__('External Link', 'cyarb-toolkit'),
                'type'      => Controls_Manager:: TEXT,
                'condition' => [
                    'link_type2' => '2',
                ]
            ]
        );
        $this->add_control(
            'cyarb_slider_items',
            [
                'label'  => esc_html__('Slider Item', 'cyarb-toolkit'),
                'type'   => Controls_Manager::REPEATER,
                'fields' => $repeater->get_controls(),
            ]
        );
		
		//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' => __('Shape 1', 'cyarb-toolkit' ),
                'type'  => Controls_Manager::MEDIA,
                'condition' => [
                    'image_shape' => 'yes',
                ]
            ]
        );
        $this->add_control(
            'shape2',
            [
                'label' => __('Shape 2', 'cyarb-toolkit' ),
                'type'  => Controls_Manager::MEDIA,
                'condition' => [
                    'image_shape' => 'yes',
                ]
            ]
        );
        $this->add_control(
            'shape3',
            [
                'label' => __('Shape 3', 'cyarb-toolkit' ),
                'type'  => Controls_Manager::MEDIA,
                'condition' => [
                    'image_shape' => 'yes',
                ]
            ]
        );
        $this->add_control(
            'shape4',
            [
                'label' => __('Shape 4', 'cyarb-toolkit' ),
                'type'  => Controls_Manager::MEDIA,
                'condition' => [
                    'image_shape' => 'yes',
                ]
            ]
        );
        $this->add_control(
            'shape5',
            [
                'label' => __('Shape 5', 'cyarb-toolkit' ),
                'type'  => Controls_Manager::MEDIA,
                'condition' => [
                    'image_shape' => 'yes',
                ]
            ]
        );
        $this->add_control(
            'shape6',
            [
                'label' => __('Shape 6', 'cyarb-toolkit' ),
                'type'  => Controls_Manager::MEDIA,
                'condition' => [
                    'image_shape' => 'yes',
                ]
            ]
        );
		$this->end_controls_section();
		
		$this->start_controls_section(
			'section_style',
			[
				'label' => __( 'Style', 'cyarb-toolkit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);
            $this->add_control(
                'title_color',
                [
                    'label'     => __( 'Title Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-content h1, .banner-content h2, .banner-content h3, .banner-content h4, .banner-content h5, .banner-content h6' => 'color: {{VALUE}}',
                    ],
                ]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'title_type_typography',
                    'label' => __( 'Title Type Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .banner-content h1, .banner-content h2, .banner-content h3, .banner-content h4, .banner-content h5, .banner-content h6',
                ]
            );
            
            $this->add_control(
                'content_color',
                [
                    'label' => __( 'Content Color', 'cyarb-toolkit' ),
                    'type'  => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-content p, .banner-content ul li, .banner-content ol li' => 'color: {{VALUE}}',
                    ],
                ]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'content_type_typography',
                    'label' => __( 'Content Type Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .banner-content p, .banner-content ul li, .banner-content ol li',
                ]
            );
            $this->add_control(
                'btn_color',
                [
                    'label' => __( 'Button One Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .default-btn' => 'color: {{VALUE}}',
                    ],
                ]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'btn_type_typography',
                    'label' => __( 'Button One Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .default-btn',
                ]
            );
            $this->add_control(
                'btn2_color',
                [
                    'label' => __( 'Button Two Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-content .btn-box .link-btn' => 'color: {{VALUE}}',
                    ],
                ]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'btn2_type_typography',
                    'label' => __( 'Button Two Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .banner-content .btn-box .link-btn',
                ]
            );
        $this->end_controls_section();

    }

	protected function render() {

		$settings = $this->get_settings_for_display();
        $slider = $settings['cyarb_slider_items']; ?>
        <div class="banner-area">
            <div class="container-fluid">
                <div class="home-slides owl-carousel owl-theme">
                    <?php foreach ($slider as $key => $value): 
                        $link_one = '';
                        if($value['link_type'] == 1){
                            $link_one = get_page_link($value['link_to_page']); 
                        } else {
                            $link_one = $value['external_link'];
                        }
                        
                        $link_two = '';
                        if($value['link_type2'] == 1){
                            $link_two = get_page_link($value['link_to_page2']); 
                        } else {
                            $link_two = $value['external_link2'];
                        }
                    ?>
                        <div class="banner-item">
                            <div class="row align-items-center">
                                <div class="col-lg-6 col-md-12">
                                    <div class="banner-content">
                                        <<?php echo esc_attr($settings['title_type']);?>><?php echo esc_html( $value['banner_title'] ); ?></<?php echo esc_attr($settings['title_type']);?>>
                                        <?php echo wp_kses_post( $value['banner_desc'] ); ?>

                                        <?php if( $value['btn_text1'] != '' || $value['btn_text2'] != '' ): ?>
                                            <div class="btn-box d-flex align-items-center">
                                                <?php if( $value['btn_text1'] != '' ): ?>
                                                    <a href="<?php echo esc_url( $link_one ); ?>" class="default-btn"><span><?php echo esc_html( $value['btn_text1'] ) ?></span></a>
                                                <?php endif; ?>

                                                <?php if( $value['btn_text2'] != '' ): ?>
                                                    <a href="<?php echo esc_url( $link_two ); ?>" class="link-btn"><?php echo esc_html( $value['btn_text2'] ) ?> <i class="lni lni-chevron-right"></i></a>
                                                <?php endif; ?>
                                            </div>
                                        <?php endif; ?>

                                    </div>
                                </div>
                                <?php if( $value['add_image']['url'] != '' ) :?>
                                    <div class="col-lg-6 col-md-12">
                                        <div class="banner-image">
                                            <img src="<?php echo esc_url($value['add_image']['url']) ?>" alt="<?php echo esc_attr('Banner image','cyarb-toolkit'); ?>">
                                        </div>
                                    </div>
                                <?php endif; ?>
                            </div>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>
            <?php if ( 'yes' === $settings['image_shape'] ) : ?>
                <?php if( $settings['shape1']['url'] != '' ) :?>
                <div class="shape1"> <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="shape2"><img src="<?php echo esc_url($settings['shape2']['url']) ?>" alt="<?php echo esc_attr('Shape','cyarb-toolkit'); ?>"></div>
                <?php endif; ?>

                <?php if( $settings['shape3']['url'] != '' ) :?>
                <div class="shape3"><img src="<?php echo esc_url($settings['shape3']['url']) ?>" alt="<?php echo esc_attr('Shape','cyarb-toolkit'); ?>"></div>
                <?php endif; ?>

                <?php if( $settings['shape4']['url'] != '' ) :?>
                <div class="shape4"><img src="<?php echo esc_url($settings['shape4']['url']) ?>" alt="<?php echo esc_attr('Shape','cyarb-toolkit'); ?>"></div>
                <?php endif; ?>

                <?php if( $settings['shape5']['url'] != '' ) :?>
                <div class="shape5"><img src="<?php echo esc_url($settings['shape5']['url']) ?>" alt="<?php echo esc_attr('Shape','cyarb-toolkit'); ?>"></div>
                <?php endif; ?>
                <?php if( $settings['shape6']['url'] != '' ) :?>
                <div class="shape12"><img src="<?php echo esc_url($settings['shape6']['url']) ?>" alt="<?php echo esc_attr('Shape','cyarb-toolkit'); ?>"></div>
                <?php endif; ?>
            <?php endif; ?>
        </div>

        <?php
	}

}

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