Untitled

 avatar
unknown
plain_text
a year ago
14 kB
5
Indexable
public function get_name() {
    return 'Prala_Categories_Destination_Two';
}

public function get_title() {
    return __( 'Destination Category Two', 'prala-toolkit' );
}

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

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

protected function register_controls() {

    $this->start_controls_section(
		'prala_categories',
		[
			'label' => __( 'Category Two Control', 'prala-toolkit' ),
			'tab' => Controls_Manager::TAB_CONTENT,
		]
	);

        $this->add_control(
            'choose_style',
            [
                'label'   => __( 'Choose Style', 'prala-toolkit' ),
                'type'    => Controls_Manager::SELECT,
                'options' => [
                    '1'         => __( 'Style One', 'prala-toolkit' ),
                    '2'         => __( 'Style Two', 'prala-toolkit' ),
                ],
                'default' => '1',
            ]
        );

        $this->add_control(
            'title',
            [
                'label' => __( 'Section Title', 'prala-toolkit' ),
                'default' => __( 'Popular Categories', 'prala-toolkit' ),
                'type' => Controls_Manager::TEXT,
            ]
        );

		$repeater = new Repeater();

        $repeater->add_control(
            'cat_name', [
				'type'          => Controls_Manager::SELECT,
				'label_block' 	=> true,
				'options'       => prala_toolkit_get_page_destination_cat_el(),
				'label'         => esc_html__( 'Select Category', 'prala-toolkit' ),
            ]
        );
        $repeater->add_control(
			'cat_img',
			[
				'label' => esc_html__( 'Images', 'prala-toolkit' ),
                'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
        );

        $this->add_control(
            'items',
            [
                'label'   => esc_html__( 'Add Item', 'prala-toolkit' ),
                'type' => Controls_Manager::REPEATER,
                'fields' => $repeater->get_controls(),
            ]
        );

    $this->end_controls_section();

    $this->start_controls_section(
		'section_style',
		[
			'label' => __( 'Style', 'prala-toolkit' ),
			'tab' => Controls_Manager::TAB_STYLE,
		]
	);
       
        $this->add_control(
            'title_color',
            [
                'label' => esc_html__( 'Title Color', 'prala-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .category-wrap h2, {{WRAPPER}} .fs-48' => 'color: {{VALUE}}',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'title_typography',
                'label' => __( 'Title Typography', 'prala-toolkit' ),
                'selector' => '{{WRAPPER}} .category-wrap h2, {{WRAPPER}} .fs-48',
            ]
        );

        $this->add_control(
			'left_sec_bg_color',
			[
				'label'     => __( 'Left Section Background Color', 'banco-toolkit' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => [
					'{{WRAPPER}} .destination-list.bg_soft' => 'background-color: {{VALUE}} !important',
				],
                'condition' => [
                    'choose_style' => '2',
                ],
			]
		);

        $this->add_control(
            'left_cat_color',
            [
                'label' => esc_html__( 'Left Category Color', 'prala-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .destination-list li a' => 'color: {{VALUE}} !important',
                ],
                'condition' => [
                    'choose_style' => '2',
                ],
            ]
        );

        $this->add_control(
            'left_cat_h_color',
            [
                'label' => esc_html__( 'Left Category Hover Color', 'prala-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .destination-list li a:hover' => 'color: {{VALUE}} !important',
                ],
                'condition' => [
                    'choose_style' => '2',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'left_cat_typography',
                'label' => __( 'Left Category Typography', 'prala-toolkit' ),
                'selector' => '{{WRAPPER}} .destination-list li a',
                'condition' => [
                    'choose_style' => '2',
                ],
            ]
        );

        $this->add_control(
            'left_sp_color',
            [
                'label' => esc_html__( 'Left Category Span Tag Color', 'prala-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .destination-list li a .text_para' => 'color: {{VALUE}} !important',
                ],
                'condition' => [
                    'choose_style' => '2',
                ],
            ]
        );

        $this->add_control(
            'left_sp_h_color',
            [
                'label' => esc_html__( 'Left Category Span Tag Hover Color', 'prala-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .destination-list li a:hover .text_para' => 'color: {{VALUE}} !important',
                ],
                'condition' => [
                    'choose_style' => '2',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'left_sp_typography',
                'label' => __( 'Left Category Span Tag Typography', 'prala-toolkit' ),
                'selector' => '{{WRAPPER}} .destination-list li a .text_para',
                'condition' => [
                    'choose_style' => '2',
                ],
            ]
        );

        $this->add_control(
            'cat_color',
            [
                'label' => esc_html__( 'Category Color', 'prala-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .map-card a, {{WRAPPER}} .text_title' => 'color: {{VALUE}} !important',
                ],
            ]
        );

        $this->add_control(
            'cat_h_color',
            [
                'label' => esc_html__( 'Category Hover Color', 'prala-toolkit' ),
                'type' => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .map-card a:hover, {{WRAPPER}} .text_title:hover' => 'color: {{VALUE}} !important',
                ],
            ]
        );

        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name' => 'cat_typography',
                'label' => __( 'Category Typography', 'prala-toolkit' ),
                'selector' => '{{WRAPPER}} .map-card a, {{WRAPPER}} .text_title',
            ]
        );
    $this->end_controls_section();
}

protected function render() {
    $settings = $this->get_settings_for_display();

    $cat_item = $settings['items'];
    ?>

    <?php if($settings['choose_style'] == '1'): ?>
        <div class="container pt-100 pb-75">
            <?php if($settings['title']): ?>
                <h2 class="fs-48 fw-normal text-center mb-40"><?php echo wp_kses_post( $settings['title'] ); ?></h2>
            <?php endif; ?>
            <div class="row justify-content-center">
                <?php
                    $i = 1;
                    foreach ($cat_item as $key => $cat):
                        if( !$cat['cat_name'] == '' ) {
                        $taxonomy = 'destination_cat';
                        $cat_link = get_term_link( $cat['cat_name'], $taxonomy);
                        $category = get_term_by('slug',  $cat['cat_name'], $taxonomy);
                        $term = get_term_by('slug', $cat['cat_name'], 'destination_cat');
                        

                ?>
                <div class="col-xl-2 col-md-4 col-6" data-aos="fade-up" data-aos-duration="1200" data-aos-delay="200">
                    <div class="map-card d-block mb-25">
                        <?php if($cat['cat_img']['url']): ?>
                            <img src="<?php echo esc_url($cat['cat_img']['url']); ?>" class="mx-auto d-block" alt="Image">
                        <?php endif; ?>
                        <a href="<?php echo esc_url($cat_link); ?>"  class="fs-24 d-block text-center mt-4 f-secondary text_title"><?php echo esc_html($category->name); ?></a>
                    </div>
                </div>
                <?php
                    }
                    $i++;
                    endforeach;
                ?>    
            </div>
        </div>
    <?php elseif($settings['choose_style'] == '2'): ?>
        <div class="container pb-75">
            <?php if($settings['title']): ?>
                <h2 class="fs-48 fw-normal text-center mb-40"><?php echo wp_kses_post( $settings['title'] ); ?></h2>
            <?php endif; ?>
            <div class="row align-items-center">
                <div class="col-xl-3 col-lg-4">
                    <ul class="destination-list list-style bg_soft">
                        <?php
                            $i = 1;
                            foreach ($cat_item as $key => $cat):
                                if( !$cat['cat_name'] == '' ) {
                                $taxonomy = 'destination_cat';
                                $cat_link = get_term_link( $cat['cat_name'], $taxonomy);
                                $category = get_term_by('slug',  $cat['cat_name'], $taxonomy);
                                $term = get_term_by('slug', $cat['cat_name'], 'destination_cat');
                                $cat_count = get_category($term); 

                        ?>
                        <li> <a href="<?php echo esc_url($cat_link); ?>"><?php echo $i; ?><?php echo esc_html__('.', 'prala'); ?> <?php echo esc_html($category->name); ?>
                        <?php if($cat_count->count ): ?><span class="text_para"><?php echo esc_html__('(', 'prala'); ?><?php echo $cat_count->count; ?><?php echo esc_html__(')', 'prala'); ?></span><?php endif; ?>
                        </a></li>
                    <?php
                        }
                        $i++;
                        endforeach;
                    ?>    
                    </ul>
                </div>
                <div class="col-xl-9 col-lg-8">
                    <div class="row justify-content-center">
                        <?php
                            $i = 1;
                            foreach ($cat_item as $key => $cat):
                                if( !$cat['cat_name'] == '' ) {
                                $taxonomy = 'destination_cat';
                                $cat_link = get_term_link( $cat['cat_name'], $taxonomy);
                                $category = get_term_by('slug',  $cat['cat_name'], $taxonomy);
                                $term = get_term_by('slug', $cat['cat_name'], 'destination_cat');
                                

                        ?>
                        <div class="col-md-4 col-6">
                            <div class="map-card style-two d-md-flex align-items-md-center mb-25">
                                <?php if($cat['cat_img']['url']): ?>
                                    <img src="<?php echo esc_url($cat['cat_img']['url']); ?>" class="mx-auto d-block" alt="Image">
                                <?php endif; ?>
                                <a href="<?php echo esc_url($cat_link); ?>"  class="fs-24 d-block text-center mt-0 f-secondary text_title"><?php echo esc_html($category->name); ?></a>
                            </div>
                        </div>
                        <?php
                            }
                            $i++;
                            endforeach;
                        ?>    
                    </div>
                </div>
            </div>
        </div>
    <?php endif; ?>

    <?php
}
Editor is loading...
Leave a Comment