File "service-area.php"

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

<?php
/**
 * Service Widget
 */
namespace Elementor;
class Cyarb_Service extends Widget_Base{
    public function get_name(){
        return "Cyarb_Service";
    }
    public function get_title(){
        return "Service";
    }
    public function get_icon(){
        return "eicon-video-camera";
    }
    public function get_categories(){
        return ['cyarb-elements'];
    }
    protected function register_controls(){

    $this->start_controls_section(
        'Cyarb_Service',
        [
            'label' => __( 'Cyarb Service', 'cyarb-toolkit' ),
            'tab' => Controls_Manager::TAB_CONTENT,
        ]
    );

        $this->add_control(
            'fimage',
            [
                'label' => esc_html__( 'Add Background Image', 'cyarb-toolkit' ),
                'type'	 => Controls_Manager::MEDIA,
            ]
        );

        $this->add_control(
            'title',
            [
                'label' => esc_html__( 'Title', 'cyarb-toolkit' ),
                'type' => Controls_Manager::TEXT,
            ]
        );

        $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(
            'content',
            [
                'label' => esc_html__( 'Content', 'cyarb-toolkit' ),
                'type'=>Controls_Manager:: WYSIWYG,
            ]
        ); 

        $repeater = new Repeater();

        $repeater->add_control(
            'card_img',
            [
                'label' => esc_html__( 'Image', 'cyarb-toolkit' ),
                'type' => Controls_Manager::MEDIA,
                'label_block' => true,
            ]
        );
        $repeater->add_control(
            'card_title',
            [
                'label' => esc_html__( 'Add Card Title', 'cyarb-toolkit' ),
                'type' => Controls_Manager::TEXT,
            ]
        );

        $repeater->add_control(
            'desc',
            [
                'label' => esc_html__( 'Add Card Content', 'cyarb-toolkit' ),
                'type'=>Controls_Manager:: WYSIWYG,
            ]
        ); 

        $this->add_control(
            'card_slider',
            [
                'label' => esc_html__( 'Add Card Items', '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-> end_controls_section();

    // Start Style content controls
    $this-> start_controls_section(
        'style',
        [
            'label'=>esc_html__('Style', 'cyarb-toolkit'),
            'tab'=> Controls_Manager::TAB_STYLE,
        ]
    );

        $this->add_control(
            'title_color',
            [
                'label' => esc_html__( 'Title Color', 'cyarb-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .section-title h1, .services-area.bg-image .section-title h2, .section-title h3, .section-title h4, .section-title h5, .section-title h6' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'title_typography',
                'label' => __( 'Title Typography', 'cyarb-toolkit' ),
                'selector' => '{{WRAPPER}} .section-title h1, .section-title h2, .section-title h3, .section-title h4, .section-title h5, .section-title h6',
            ]
        );

        $this->add_control(
            'desc_color',
            [
                'label' => esc_html__( 'Description Color', 'cyarb-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .services-area.bg-image .section-title p' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'desc_typography',
                'label' => __( 'Description Typography', 'cyarb-toolkit' ),
                'selector' => '{{WRAPPER}} p',
            ]
        );

        $this->add_control(
            'card_title_color',
            [
                'label' => esc_html__( 'Card Title Color', 'cyarb-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .single-services-box h3' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'card_title_typography',
                'label' => __( 'Card Title Typography', 'cyarb-toolkit' ),
                'selector' => '{{WRAPPER}} .single-services-box h3',
            ]
        );

        $this->add_control(
            'card_desc_color',
            [
                'label' => esc_html__( 'Card Description Color', 'cyarb-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} p' => 'color: {{VALUE}}',
                ],
            ]
        );
    $this-> end_controls_section();
}
    protected function render()
    {
        $settings = $this->get_settings_for_display();

        $slider         = $settings['card_slider'];

        ?>
        <div class="services-area pt-100 pb-75 bg-image" style="background-image:url(<?php echo esc_url( $settings['fimage']['url'] ); ?>);">
            <div class="container">
                <div class="section-title">
                    <<?php echo esc_attr( $settings['title_tag'] ); ?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr( $settings['title_tag'] ); ?>>
                    <?php echo wp_kses_post( $settings['content'] ); ?>
                </div>
                <div class="row justify-content-center">
                    <?php foreach( $settings['card_slider'] as $item ): ?>
                        <div class="col-lg-4 col-md-6">
                            <div class="single-services-box style-two">
                                <div class="icon">
                                    <img src="<?php echo esc_url( $item['card_img']['url'] ); ?>" alt="<?php echo esc_attr( $item['card_title'] ); ?>">
                                </div>
                                <h3><?php echo esc_html( $item['card_title'] ); ?></h3>
                                <?php echo wp_kses_post( $item['desc'] ); ?>
                            </div>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>

            <?php if ( 'yes' === $settings['image_shape'] ) : ?>
                <div class="shape1"><img src="<?php echo esc_url(get_template_directory_uri() .'/assets/img/shape/shape1.png' ); ?>" alt="<?php echo esc_attr__( 'Shape', 'cyarb-toolkit' ); ?>"></div>
                <div class="shape3"><img src="<?php echo esc_url(get_template_directory_uri() .'/assets/img/shape/shape3.png' ); ?>" alt="<?php echo esc_attr__( 'Shape', 'cyarb-toolkit' ); ?>"></div>
                <div class="shape6"><img src="<?php echo esc_url(get_template_directory_uri() .'/assets/img/shape/shape6.png' ); ?>" alt="<?php echo esc_attr__( 'Shape', 'cyarb-toolkit' ); ?>"></div>
            <?php endif; ?>
        </div>
    <?php
    }

    
}
Plugin::instance()->widgets_manager->register_widget_type( new Cyarb_Service );