File "banner-three.php"

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

<?php
/**
 * Banner Three Widget
 */

namespace Elementor;
class Cyarb_Banner_Three extends Widget_Base {

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

	public function get_title() {
        return __( 'Banner Three', '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' => __( 'Cyarb Banner Three', 'cyarb-toolkit' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			]
		);

        $this->add_control(
            'add_image',
            [
                'label' => __('Add Banner Background Image', 'cyarb-toolkit' ),
                'type'  => Controls_Manager::MEDIA,
                'default' => [
                    'url' => Utils::get_placeholder_image_src(),
                ]
            ]
        );

        $this->add_control(
            'banner_title', [
                'label' => __( 'Add Banner Title', 'cyarb-toolkit' ),
                'type'  => Controls_Manager:: TEXTAREA,
            ]
		);
		
		$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'
            ]
        );

        $this->add_control(
            'banner_desc',
            [
                'label'       =>__('Banner Description', 'cyarb-toolkit'),
                'type'        => Controls_Manager:: WYSIWYG,
                'description' => __('This text editor for p','cyarb-toolkit'),
            ]
		);
        $this->add_control(
            'btn_text1',
            [
                'label' => esc_html__('Button One Title', 'cyarb-toolkit'),
                'type'  => Controls_Manager:: TEXT,
            ]
        );
        $this->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' ),
                ],
            ]
        );
        $this->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',
                ]
            ]
        );
        $this->add_control(
            'external_link',
            [
                'label'     => esc_html__('External Link', 'cyarb-toolkit'),
                'type'      => Controls_Manager:: TEXT,
                'condition' => [
                    'link_type' => '2',
                ]
            ]
        );
        // Button Two
        $this->add_control(
            'btn_text2',
            [
                'label' => esc_html__('Button Two Title', 'cyarb-toolkit'),
                'type'  => Controls_Manager:: TEXT,
            ]
        );
        $this->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' ),
                ],
            ]
        );
        $this->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',
                ]
            ]
        );
        $this->add_control(
            'external_link2',
            [
                'label'     => esc_html__('External Link', 'cyarb-toolkit'),
                'type'      => Controls_Manager:: TEXT,
                'condition' => [
                    'link_type2' => '2',
                ]
            ]
        );

        $this->add_control(
            'video_link',
            [
                'label'     => esc_html__('Video Link', 'cyarb-toolkit'),
                'type'      => Controls_Manager:: TEXT,
            ]
        );
		
		//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->end_controls_section();

        // Banner Bottom Services
        $this->start_controls_section(
			'Cyarb_Banner_bottom_Area',
			[
				'label' => __( 'Banner Bottom Controls', 'cyarb-toolkit' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			]
		);
            $this->add_control(
                'count',
                [
                    'label' => __( 'Post Per Page', 'cyarb-toolkit' ),
                    'default' => __( '3', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::TEXT,
                    'description' => __('if you want to see all post type -1','cyarb-toolkit')
                ]
            );
            $this->add_control(
                'cat_name',
                [
                    'label' => __( 'Select Category', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::SELECT,
                    'options' => cyarb_toolkit_get_product_cat_list(),
                ]
            );
            $this->add_control(
                'order',
                [
                    'label' => __( 'Select Order', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::SELECT,
                    'options' => [
                        'DESC'  => __( 'DESC', 'cyarb-toolkit' ),
                        'ASC'  => __( 'ASC', 'cyarb-toolkit' ),
                    ],
                    'default' => 'DESC',
                ]
            );
            $this->add_control(
                'excerpt_num',
                [
                    'label'   => __( 'Excerpt', 'cyarb-toolkit' ),
                    'type'    => Controls_Manager::NUMBER,
                    'default' => 25,
                ]
            );
		$this->end_controls_section();
		
        // Styling
		$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-wrapper-content h1, .banner-wrapper-content h2, .banner-wrapper-content h3, .banner-wrapper-content h4, .banner-wrapper-content h5, .banner-wrapper-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-wrapper-content h1, .banner-wrapper-content h2, .banner-wrapper-content h3, .banner-wrapper-content h4, .banner-wrapper-content h5, .banner-wrapper-content h6',
                ]
            );
            
            $this->add_control(
                'content_color',
                [
                    'label' => __( 'Content Color', 'cyarb-toolkit' ),
                    'type'  => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-wrapper-content p, .banner-wrapper-content ul li, .banner-wrapper-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-wrapper-content p, .banner-wrapper-content ul li, .banner-wrapper-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_control(
                'btn_cbgolor',
                [
                    'label' => __( 'Button One Background Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .default-btn' => 'background: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'btn_hcolor',
                [
                    'label' => __( 'Button One Hover Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .default-btn:hover' => 'color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'btn_hbgcolor',
                [
                    'label' => __( 'Button One Hover Background Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-wrapper-content .btn-box .default-btn::before, .banner-wrapper-content .btn-box .default-btn::after, .banner-wrapper-content .btn-box .default-btn span::before, .banner-wrapper-content .btn-box .default-btn span::after' => 'background: {{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-wrapper-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-wrapper-content .btn-box .link-btn',
                ]
            );

            $this->add_control(
                'video_bordercolor',
                [
                    'label' => __( 'Video Border Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-wrapper-video .video-btn::after, .banner-wrapper-video .video-btn::before' => 'border-color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'video_color',
                [
                    'label' => __( 'Video Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-wrapper-video .video-btn' => 'background-color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'video_icolor',
                [
                    'label' => __( 'Video Icon Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-wrapper-video .video-btn' => 'color: {{VALUE}}',
                    ],
                ]
            );
        $this->end_controls_section();

        $this->start_controls_section(
			'section_bottom_style',
			[
				'label' => __( 'Bottom Style', 'cyarb-toolkit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);
            $this->add_control(
                'card_bg_color',
                [
                    'label' => __( 'Cart Background Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-boxes-area .single-features-box' => 'background: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'card_bg_hcolor',
                [
                    'label' => __( 'Cart Hover Background Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-boxes-area .single-features-box:hover' => 'background: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'btitle_color',
                [
                    'label'     => __( 'Bottom Title Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .single-features-box h3 a' => 'color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'btitle_hcolor',
                [
                    'label'     => __( 'Bottom Title Hover Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .single-features-box:hover h3 a' => 'color: {{VALUE}}',
                    ],
                ]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'btitle_type_typography',
                    'label' => __( 'Bottom Title Type Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .single-features-box h3',
                ]
            );
            $this->add_control(
                'bcon_color',
                [
                    'label'     => __( 'Bottom Content Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .single-features-box p' => 'color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'bcon_hcolor',
                [
                    'label'     => __( 'Bottom Content Hover Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .single-features-box:hover p' => 'color: {{VALUE}}',
                    ],
                ]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'bcon_type_typography',
                    'label' => __( 'Bottom Content Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .single-features-box p',
                ]
            );

            $this->add_control(
                'b_icon_color',
                [
                    'label'     => __( 'Bottom Icon Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .banner-boxes-area .single-features-box .icon' => 'background: {{VALUE}}',
                    ],
                ]
            );

        $this->end_controls_section();

    }

	protected function render() {

		$settings = $this->get_settings_for_display();

        if( $settings['cat_name'] != '' ) {
            $args = array(
                'post_type' => 'service',
                'posts_per_page' => $settings['count'],
                'order' => $settings['order'],
                'tax_query' => array(
                    array(
                        'taxonomy' => 'service_cat',
                        'field' => 'slug',
                        'terms' => $settings['cat_name'],
                        'hide_empty' => false
                    )
                )
            );
        } else {
            $args = array(
                'post_type' => 'service',
                'posts_per_page' => $settings['count'],
                'order' => $settings['order'],
            );
        }
        $services_array = new \WP_Query( $args ); 

        $link_one = '';
        if($settings['link_type'] == 1){
            $link_one = get_page_link($settings['link_to_page']); 
        } else {
            $link_one = $settings['external_link'];
        }
        
        $link_two = '';
        if($settings['link_type2'] == 1){
            $link_two = get_page_link($settings['link_to_page2']); 
        } else {
            $link_two = $settings['external_link2'];
        }
        
        ?>
        <div class="banner-wrapper-area" style="background-image:url(<?php echo esc_url( $settings['add_image']['url'] ); ?>);">
            <div class="container">
                <div class="row align-items-center">
                    <div class="col-lg-6 col-md-12">
                        <div class="banner-wrapper-content">
                            <<?php echo esc_attr($settings['title_type']);?>><?php echo esc_html( $settings['banner_title'] ); ?></<?php echo esc_attr($settings['title_type']);?>>
							<?php echo wp_kses_post( $settings['banner_desc'] ); ?>

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

                                    <?php if( $settings['btn_text2'] != '' ): ?>
                                        <a href="<?php echo esc_url( $link_two ); ?>" class="link-btn"><?php echo esc_html( $settings['btn_text2'] ) ?> <i class="lni lni-chevron-right"></i></a>
                                    <?php endif; ?>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div>
                    <?php if( $settings['video_link'] != '' ): ?>
                        <div class="col-lg-6 col-md-12">
                            <div class="banner-wrapper-video">
                                <a href="<?php echo esc_url( $settings['video_link'] ); ?>" class="video-btn popup-video"><i class="lni lni-play"></i></a>
                            </div>
                        </div>
                    <?php endif; ?>
                </div>
                <div class="banner-boxes-area">
                    <div class="row justify-content-center">
                        <?php while($services_array->have_posts()): $services_array->the_post();
                            // ACF field access
                            if (class_exists( 'ACF') && get_field('service_icon_image')){
                                $icon_img      = get_field('service_icon_image');
                            } else {
                                $icon_img      = '';
                            } 
                            $id = get_the_ID();
                        ?>
                        <div class="col-lg-4 col-md-6">
                            <div class="single-features-box">
                                <?php if( $icon_img != '') : ?>
                                    <div class="icon">
                                        <img src="<?php echo esc_url($icon_img); ?>" alt="<?php echo esc_attr__('services-icon','cyarb-toolkit'); ?>">
                                    </div>
                                <?php endif; ?>
                                <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                    
                                <p><?php echo esc_html(wp_trim_words( get_the_excerpt(), $settings['excerpt_num'], '' )); ?></p>
                            </div>
                        </div>
                        <?php endwhile; wp_reset_query(); ?>
                    </div>
                </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="shape3"><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="shape4"><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="shape5"><img src="<?php echo esc_url($settings['shape4']['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_Three );