File "services.php"

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

<?php
/**
 * Services Area Widget
 */

namespace Elementor;

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class Cyarb_Servcies_Area extends Widget_Base {

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

	public function get_title() {
        return esc_html__( 'Services', 'cyarb-toolkit' );
    }

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

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

	protected function register_controls() {

        $this->start_controls_section(
			'Cyarb_Features_Area_controls',
			[
				'label' => esc_html__( 'Services Area Controls', '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' ),
                        '3'         => __( 'Style Three', 'cyarb-toolkit' ),
                    ],
                    'default' => '1',
                ]
            );
            $this->add_control(
                'title',
                [
                    'label' => esc_html__( 'Title', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::TEXTAREA,
                ]
            );
            $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'),
                    'condition' => [
                        'choose_style' => ['2','3'],
                    ]
                ]
            );
            $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' ),
                    ],
                    'condition' => [
                        'choose_style' => ['2','3'],
                    ] 
                ]
            );
            $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',
                        'choose_style' => ['2','3'],
                    ]
                ]
            );
            $this->add_control(
                'external_link',
                [
                    'label'     =>__('External Link', 'cyarb-toolkit'),
                    'type'      => Controls_Manager:: TEXT,
                    'condition' => [
                        'link_type'    => '2',
                        'choose_style' => ['2','3'],
                    ]
                ]
            );
            //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',
                    'condition' => [
                        'choose_style' => ['2','3'],
                    ]
                ]
            );
            $this->add_control(
                'desc',
                [
                    'label'       =>__('Add Description', 'cyarb-toolkit'),
                    'type'        => Controls_Manager:: WYSIWYG,
                    'description' => __('This text editor for p','cyarb-toolkit'),
                    'condition' => [
                        'choose_style' => '1',
                    ]
                ]
            );
            $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' => 15,
                ]
            );
            $this->add_control(
                'read_more_btntext',
                [
                    'label'     => __( 'Read More Button Text', 'cyarb-toolkit' ),
                    'default'   => __( 'Read More', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::TEXT,
                    'condition' => [
                        'choose_style' => '1',
                    ]
                ]
            );
            $this->add_control(
				'shape1', [
					'label' => __( 'Shape Image 1', 'cyarb-toolkit' ),
					'type'  => Controls_Manager::MEDIA,
                    'condition' => [
                        'choose_style' => '1',
                    ]
				]
			);
        $this->end_controls_section();

        $this->start_controls_section(
			'style',
			[
				'label' => esc_html__( 'Style', 'cyarb-toolkit' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);
            $this->add_control(
                'sec_title_color',
                [
                    'label' => esc_html__( 'Section Title Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .section-title h2, .section-title h3, .section-title h4, .section-title h5, .section-title h6, .section-title h1, .section-title-wrap .wrap-title h2, .section-title-wrap .wrap-title h1, .section-title-wrap .wrap-title h3, .section-title-wrap .wrap-title h4, .section-title-wrap .wrap-title h5, .section-title-wrap .wrap-title h6, .body-with-black-color .section-title-wrap .wrap-title h2, .body-with-black-color .section-title-wrap .wrap-title h1, .body-with-black-color .section-title-wrap .wrap-title h3, .body-with-black-color .section-title-wrap .wrap-title h4, .body-with-black-color .section-title-wrap .wrap-title h5, .body-with-black-color .section-title-wrap .wrap-title h6' => 'color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'sec_title_typography',
                    'label' => __( 'Section Title Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .section-title h2, .section-title h3, .section-title h4, .section-title h5, .section-title h6, .section-title h1, .section-title-wrap .wrap-title h2, .section-title-wrap .wrap-title h1, .section-title-wrap .wrap-title h3, .section-title-wrap .wrap-title h4, .section-title-wrap .wrap-title h5, .section-title-wrap .wrap-title h6, .body-with-black-color .section-title-wrap .wrap-title h2, .body-with-black-color .section-title-wrap .wrap-title h1, .body-with-black-color .section-title-wrap .wrap-title h3, .body-with-black-color .section-title-wrap .wrap-title h4, .body-with-black-color .section-title-wrap .wrap-title h5, .body-with-black-color .section-title-wrap .wrap-title h6',
                ]
            );
            $this->add_control(
                'sec_desc_color',
                [
                    'label' => esc_html__( 'Section Description Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .section-title p' => 'color: {{VALUE}}',
                    ],
                    'condition' => [
                        'choose_style' => '1',
                    ]
                ]
            );
            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'sec_desc_typography',
                    'label' => __( 'Section Description Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .section-title p',
                    'condition' => [
                        'choose_style' => '1',
                    ]
                ]
            );
            $this->add_control(
                'title_color',
                [
                    'label' => esc_html__( 'Title Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .safer-world-card .safer-world-content h3 a, .get-privacy-card .get-privacy-content h3 a, .body-with-black-color .get-privacy-card .get-privacy-content h3 a' => 'color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'title_typography',
                    'label' => esc_html__( 'Title Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .safer-world-card .safer-world-content h3 a, .get-privacy-card .get-privacy-content h3 a, .body-with-black-color .get-privacy-card .get-privacy-content h3 a',
                ]
            );
            $this->add_control(
                'con_color',
                [
                    'label' => esc_html__( 'Excerpt Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .safer-world-card .safer-world-content p, .get-privacy-card .get-privacy-content p, .body-with-black-color .get-privacy-card .get-privacy-content p' => 'color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'ex_typography',
                    'label' => esc_html__( 'Excerpt Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .safer-world-card .safer-world-content p, .get-privacy-card .get-privacy-content p, .body-with-black-color .get-privacy-card .get-privacy-content p',
                ]
            );
            $this->add_control(
                'btn_color',
                [
                    'label' => esc_html__( 'Button Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .safer-world-card .safer-world-content .safer-world-btn' => 'background-color: {{VALUE}}',
                    ],
                    'condition' => [
                        'choose_style' => '1',
                    ]
                ]
            );
            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'btn_typography',
                    'label' => esc_html__( 'Button Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .safer-world-card .safer-world-content .safer-world-btn',
                    'condition' => [
                        'choose_style' => '1',
                    ]
                ]
            );
            $this->add_control(
                'card_color',
                [
                    'label' => esc_html__( 'Card Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .safer-world-slides .owl-item.active.center .safer-world-card, .get-privacy-card, .body-with-black-color .get-privacy-card' => 'background-color: {{VALUE}}',
                    ],
                ]
            );
            $this->add_control(
                'card_hcolor',
                [
                    'label' => esc_html__( 'Card Hover Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .get-privacy-card:hover, .body-with-black-color .get-privacy-card:hover' => 'background-color: {{VALUE}}',
                    ],
                    'condition' => [
                        'choose_style' => ['2','3'],
                    ]
                ]
            );

            $this->add_control(
                'sec_btncolor',
                [
                    'label' => esc_html__( 'Section Button Color', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .default-btn-two' => 'color: {{VALUE}}',
                    ],
                    'condition' => [
                        'choose_style' => ['2','3'],
                    ]
                ]
            );
            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name'     => 'secbtn_type_typography',
                    'label'    => __( 'Button Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .default-btn-two',
                    'condition' => [
                        'choose_style' => ['2','3'],
                    ]
                ]
            );
            $this->add_control(
                'btn_bg_head',
                [
                    'label'     => esc_html__( 'Button Background Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::HEADING,
                    'separator' => 'before',
                    'condition' => [
                        'choose_style' => ['2','3'],
                    ]
                ]
            );
            $this->add_group_control(
                Group_Control_Background::get_type(),
                [
                    'name'     => 'btn_bg2_color',
                    'types'    => ['gradient' ],
                    'selector' => '{{WRAPPER}} .default-btn-two',
                    'condition' => [
                        'choose_style' => ['2','3'],
                    ]
                ]
            );
            $this->add_control(
				'onedivider',
				[
					'type' => Controls_Manager::DIVIDER,
				]
			);
            $this->add_control(
				'twodivider',
				[
					'type' => Controls_Manager::DIVIDER,
				]
			);
            $this->add_control(
                'secbtn_hcolor',
                [
                    'label'     => __( 'Button Hover Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}}  .default-btn-two:hover' => 'color: {{VALUE}}',
                    ],
                    'condition' => [
                        'choose_style' => ['2','3'],
                    ]
                ]
            );
            $this->add_control(
                'btn_hbg_head',
                [
                    'label'     => esc_html__( 'Section Button Hover Background Color', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::HEADING,
                    'separator' => 'before',
                    'condition' => [
                        'choose_style' => ['2','3'],
                    ]
                ]
            );
            $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','3'],
                    ]
                ]
            );
        $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 );

        $btn1_text  = $settings['button_text'];
        $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="safer-world-area pt-100 pb-75">
                <div class="container-fluid">
                    <?php if ( $settings['title'] != '' || $settings['desc'] != '' ) : ?>
                        <div class="section-title">
                            <<?php echo esc_attr($settings['title_tag']);?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr($settings['title_tag']);?>>
                            <p><?php echo wp_kses_post( $settings['desc'] ); ?></p>
                        </div>
                    <?php endif; ?>

                    <div class="safer-world-slides owl-carousel owl-theme">
                        <?php while($services_array->have_posts()): $services_array->the_post(); ?>
                            <div class="safer-world-card">
                                <?php if ( get_the_post_thumbnail_url() ) { ?>
                                    <div class="safer-world-image">
                                        <a href="<?php the_permalink(); ?>">
                                            <img src="<?php echo esc_url( get_the_post_thumbnail_url() ); ?>" alt="<?php echo esc_attr__('services img','cyarb-toolkit'); ?>">
                                        </a>
                                    </div>
                                <?php } ?>

                                <div class="safer-world-content">
                                    <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>

                                    <?php if( $settings['read_more_btntext'] != '' ) : ?>
                                        <a href="<?php the_permalink(); ?>" class="safer-world-btn"><?php echo esc_html( $settings['read_more_btntext'] ); ?> <i class="lni lni-arrow-right"></i></a>
                                    <?php endif; ?>
                                </div>
                            </div>
                        <?php endwhile; wp_reset_query(); ?>
                    </div>
                </div>
                <?php if( $settings['shape1']['url'] != '' ) : ?>
                    <div class="safer-world-shape">
                        <img src="<?php echo esc_url( $settings['shape1']['url'] ); ?>" alt="<?php echo esc_attr__( 'Shape1', 'cyarb-toolkit' ); ?>">
                    </div>
                <?php endif; ?>
            </div>
        <?php elseif( $settings['choose_style'] == '2' ) : ?>
            <div class="get-privacy-area pt-100 pb-75">
                <div class="container">
                    <?php if ( $settings['title'] != '' || $btn1_text != '' ) : ?>
                        <div class="section-title-wrap">
                            <div class="row align-items-center">
                                <?php if ( $settings['title'] != '' ) : ?>
                                    <div class="col-lg-7 col-md-12">
                                        <div class="wrap-title">
                                            <<?php echo esc_attr($settings['title_tag']);?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr($settings['title_tag']);?>>
                                        </div>
                                    </div>
                                <?php endif; ?>

                                <?php if($btn1_text != '') { 
                                    if ( 'yes' === $settings['target_page'] ) { ?>
                                        <div class="col-lg-5 col-md-12">
                                            <div class="wrap-btn">
                                                <a target="_blank" href="<?php echo esc_url($link_source); ?>" class="default-btn-two">
                                                    <span><?php echo esc_html($btn1_text); ?></span>
                                                </a>
                                            </div>
                                        </div>
                                    <?php } else { ?>
                                        <div class="col-lg-5 col-md-12">
                                            <div class="wrap-btn">
                                                <a href="<?php echo esc_url($link_source); ?>" class="default-btn-two">
                                                    <span><?php echo esc_html($btn1_text); ?></span>
                                                </a>
                                            </div>
                                        </div>
                                    <?php }  
                                } ?>
                            </div>
                        </div>
                    <?php endif; ?>

                    <div class="get-privacy-slides owl-carousel owl-theme">
                        <?php while($services_array->have_posts()): $services_array->the_post(); ?>
                            <div class="get-privacy-card">
                                <?php if ( get_the_post_thumbnail_url() ) { ?>
                                    <div class="get-privacy-image">
                                        <a href="<?php the_permalink(); ?>">
                                            <img src="<?php echo esc_url( get_the_post_thumbnail_url() ); ?>" alt="<?php echo esc_attr__('services img','cyarb-toolkit'); ?>">
                                        </a>
                                    </div>
                                <?php } ?>

                                <div class="get-privacy-content">
                                    <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 else: ?>
            <div class="get-privacy-area pt-100 pb-75">
                <div class="container">
                    <?php if ( $settings['title'] != '' || $btn1_text != '' ) : ?>
                        <div class="section-title-wrap">
                            <div class="row align-items-center">
                                <?php if ( $settings['title'] != '' ) : ?>
                                    <div class="col-lg-7 col-md-12">
                                        <div class="wrap-title">
                                            <<?php echo esc_attr($settings['title_tag']);?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr($settings['title_tag']);?>>
                                        </div>
                                    </div>
                                <?php endif; ?>

                                <?php if($btn1_text != '') { 
                                    if ( 'yes' === $settings['target_page'] ) { ?>
                                        <div class="col-lg-5 col-md-12">
                                            <div class="wrap-btn">
                                                <a target="_blank" href="<?php echo esc_url($link_source); ?>" class="default-btn-two">
                                                    <span><?php echo esc_html($btn1_text); ?></span>
                                                </a>
                                            </div>
                                        </div>
                                    <?php } else { ?>
                                        <div class="col-lg-5 col-md-12">
                                            <div class="wrap-btn">
                                                <a href="<?php echo esc_url($link_source); ?>" class="default-btn-two">
                                                    <span><?php echo esc_html($btn1_text); ?></span>
                                                </a>
                                            </div>
                                        </div>
                                    <?php }  
                                } ?>
                            </div>
                        </div>
                    <?php endif; ?>
                </div>

                <div class="container-fluid">
                    <div class="get-privacy-slides owl-carousel owl-theme">
                        <?php while($services_array->have_posts()): $services_array->the_post(); ?>
                            <div class="get-privacy-card">
                                <?php if ( get_the_post_thumbnail_url() ) { ?>
                                    <div class="get-privacy-image">
                                        <a href="<?php the_permalink(); ?>">
                                            <img src="<?php echo esc_url( get_the_post_thumbnail_url() ); ?>" alt="<?php echo esc_attr__('services img','cyarb-toolkit'); ?>">
                                        </a>
                                    </div>
                                <?php } ?>
                                <div class="get-privacy-content">
                                    <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 endif; ?>
        <?php
	}

}

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