File "case-details.php"

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

<?php
namespace Elementor;

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

class Cyarb_Marketing_Area extends Widget_Base {

	public function get_name() {
		return 'cyarb-marketing';
	}

	public function get_title() {
		return __( 'Case Details', 'cyarb-toolkit' );
	}

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

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

	protected function register_controls() {

        $this->start_controls_section(
			'Cyarb_Case_Details_controls',
			[
				'label' => esc_html__( 'Case Details Controls', 'cyarb-toolkit' ),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
        );

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

            $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' => 'h1',
                ]
            );

            $this->add_control(
                'content',
                [
                    'label' => esc_html__( 'Content', 'cyarb-toolkit' ),
                    'type'=>Controls_Manager:: WYSIWYG,
                ]
            ); 

            $repeater = new Repeater();

            $repeater->add_control(
                'icon_type',
                [
                    'label' => __( 'Icon Type', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::SELECT,
                    'label_block' => true,
                    'options' => [
                        '1'  =>__( 'LineIcons Font', 'cyarb-toolkit' ),
                        '2'  => __('Font Awesome', 'cyarb-toolkit' ),
                    ], 
                    'default' => '1',
                ]
            );
    
            $repeater->add_control(
                'lineicon1',
                [
                    'label' => esc_html__( 'Choose Line Icon', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::TEXT,
                    'condition' => [
                        'icon_type' => '1',
                    ],
                ]
            );
            $repeater->add_control(
                'icon1', [
                    'label' => __( 'Social Icon One', 'cyarb-toolkit' ),
                    'type' => Controls_Manager::ICONS,
                    'default' => [
                        'value' => 'fa fa-phone',
                        'library' => 'solid',
                    ],
                    'condition' => [
                        'icon_type' => '2',
                    ],
                ]
            );

            $repeater->add_control(
                'card_title', [
                    'label'     => esc_html__( 'Card Title', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::TEXT,
                ]
            );
            $repeater->add_control(
                'card_url', [
                    'label'     => esc_html__( 'Card URL', 'cyarb-toolkit' ),
                    'type'      => Controls_Manager::TEXT,
                ]
            );
            $repeater->add_control(
                'card_content', [
                    'label'     => esc_html__( 'Card Content', 'cyarb-toolkit' ),
                    'type'=>Controls_Manager:: TEXT,
                ]
            );
            $this->add_control(
                'card_item',
                [
                    'label' => esc_html__('Card Item', 'cyarb-toolkit'),
                    'type' => Controls_Manager::REPEATER,
                    'fields' => $repeater->get_controls(),
                ]
            );

        $this->end_controls_section();

        $this->start_controls_section(
			'Cyarb_Case_slider_controls',
			[
				'label' => esc_html__( 'Case Slider Details Controls', 'cyarb-toolkit' ),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
        );

            $repeater2 = new Repeater();

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

            $repeater2->add_control(
                'case_content',
                [
                    'label' => esc_html__( 'Case Content', 'cyarb-toolkit' ),
                    'type'=>Controls_Manager:: WYSIWYG,
                ]
            ); 

            $this->add_control(
                'slider_item',
                [
                    'label' => esc_html__('Slider Item', 'cyarb-toolkit'),
                    'type' => Controls_Manager::REPEATER,
                    'fields' => $repeater2->get_controls(),
                ]
            );

        $this->end_controls_section();

        $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}} .case-studies-details-header .content h1, .case-studies-details-header .content h2, .case-studies-details-header .content h3, .case-studies-details-header .content h4, .case-studies-details-header .content h5, .case-studies-details-header .content h6' => 'color: {{VALUE}}',
                    ],
                ]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'title_typography',
                    'label' => esc_html__( 'Title Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .case-studies-details-header .content h1, .case-studies-details-header .content h2, .case-studies-details-header .content h3, .case-studies-details-header .content h4, .case-studies-details-header .content h5, .case-studies-details-header .content h6',
                ]
            );

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

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'desc_typography',
                    'label' => esc_html__( '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}} .case-studies-details-header .content .meta li span' => 'color: {{VALUE}}',
					],
				]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'card_title_typography',
                    'label' => esc_html__( 'Card Title Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .case-studies-details-header .content .meta li span',
                ]
            );

            $this->add_control(
				'card_content_color',
				[
					'label' => esc_html__( 'Card Content Color', 'cyarb-toolkit' ),
					'type' => Controls_Manager::COLOR,
					'selectors' => [
						'{{WRAPPER}} .case-studies-details-header .content .meta li a, .case-studies-details-header .content .meta li' => 'color: {{VALUE}}',
					],
				]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'card_content_typography',
                    'label' => esc_html__( 'Card Content Typography', 'cyarb-toolkit' ),
                    'selector' => '{{WRAPPER}} .case-studies-details-header .content .meta li',
                ]
            );

        $this->end_controls_section();

    }

	protected function render() {

		$settings = $this->get_settings_for_display();

        global $cyarb_opt;

        $count_cat          = !empty($cyarb_opt['count_tag']) ? $cyarb_opt['count_tag'] : 1;
        
        ?>
        <div class="case-studies-details-area ptb-100">
            <div class="container">
                <div class="case-studies-details-header row align-items-center justify-content-center">
                    <div class="col-lg-6 col-md-12">
                        <div class="image">
                            <img src="<?php echo esc_url($settings['add_image']['url']) ?>" alt="<?php echo esc_attr('card image','cyarb-toolkit'); ?>">
                        </div>
                    </div>
                    <div class="col-lg-6 col-md-12">
                        <div class="content">
                            <<?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'] ); ?>
                            <ul class="meta">
                                <?php foreach( $settings['card_item'] as $item ): ?>
                                    <li>
                                        <?php if( $item['icon1'] != '' || $item['lineicon1']!='' ): ?>
                                            <?php if( $item['icon_type'] == 1 ){ ?>
                                                <i class="<?php echo esc_attr($item['lineicon1']);?>"></i>
                                            <?php } else {
                                                \Elementor\Icons_Manager::render_icon( $item['icon1'], [ 'aria-hidden' => 'true' ] ); 
                                            } ?>
                                        <?php endif; ?>

                                        <span><?php echo esc_html( $item['card_title'] ); ?></span>
                                        <a href="<?php echo esc_html( $item['card_url'] ); ?>" target="_blank"><?php echo esc_html( $item['card_content'] ); ?></a>
                                    </li><?php 
                                endforeach; 
                                ?>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="case-studies-details-desc">
                    <div class="article-content">
                        <?php foreach( $settings['slider_item'] as $item2 ): ?>
                            <h3><?php echo esc_html( $item2['case_title'] ); ?></h3>
                            <?php echo wp_kses_post( $item2['case_content'] ); ?><?php 
                        endforeach; 
                        ?>

                        <div class="article-tags">
                            <?php 

                            $terms =  get_terms( 'case_tag', array( 'post_type' => 'case' ) );
                                if( !empty( $terms ) && ! is_wp_error( $terms )) {
                                    $i = 1;

                                    foreach ( $terms as $term ) {?>
                                        <a href="<?php the_permalink(); ?>">#<?php echo "$term->name";?></a>
                                    <?php }

                                    if( $i == $count_cat  ){ ;
                                        $i++;
                                    }
                                } 
                            ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php
	}

}

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