HEX
Server: LiteSpeed
System: Linux dune179.sitesanctuary.org 5.14.0-427.40.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 16 07:08:17 EDT 2024 x86_64
User: h278792 (1076)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/h278792/public_html/wp-content/plugins/ecademy-toolkit/widgets/events.php
<?php
/**
 * Events Widget
 */

namespace Elementor;

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

class eCademy_Events extends Widget_Base {

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

	public function get_title() {
        return __( 'رویدادها', 'ecademy-toolkit' );
    }

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

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

	protected function register_controls() {

        $this->start_controls_section(
			'course_section',
			[
				'label' => __( 'رویدادها', 'ecademy-toolkit' ),
				'tab' => Controls_Manager::TAB_CONTENT,
			]
        );

        $this->add_control(
            'style',
            [
                'label' => __( 'سبک', 'ecademy-toolkit' ),
                'type' => Controls_Manager::SELECT,
                'options' => [
					'1'      => __( 'سبک 1', 'ecademy-toolkit' ),
					'2'       => __( 'سبک', 'ecademy-toolkit' ),
					'3'       => __( '  سبک 3', 'ecademy-toolkit' ),
					'4'       => __( '  سبک 4', 'ecademy-toolkit' ),
				],
				'default' => '1',
            ]
        );

        $repeater = new Repeater();
        $repeater->add_control(
            'cat_name', [
                'label' => __( 'انتخاب دسته بندی', 'upkeep-toolkit' ),
                'type' => Controls_Manager::SELECT,
                'options' => ecademy_toolkit_get_events_cat_list(),
            ]
        );
        $this->add_control(
            'tp_event_category',
            [
                'label' => esc_html__('افزودن مورد فیلتر', 'upkeep-toolkit'),
                'type' => Controls_Manager::REPEATER,
                'fields' => $repeater->get_controls(),
            ]
        );

        $this->add_control(
            'all_text',
            [
                'label'     => __( 'تمام متن', 'ecademy-toolkit' ),
                'type'      => Controls_Manager::TEXT,
				'default'   => 'همه',
                'condition' => [
                    'style' => '1',
                ]
            ]
        );

        $this->add_control(
            'order',
            [
                'label' => __( 'رویدادها به ترتیب', 'ecademy-toolkit' ),
                'type' => Controls_Manager::SELECT,
                'options' => [
					'DESC'      => __( 'DESC', 'ecademy-toolkit' ),
					'ASC'       => __( 'ASC', 'ecademy-toolkit' ),
				],
				'default' => 'DESC',
            ]
        );

        $this->add_control(
			'count',
			[
				'label' => __( 'شمردن ', 'ecademy-toolkit' ),
				'type' => Controls_Manager::NUMBER,
				'default' => 9,
			]
        );

        $this->end_controls_section();

        $this->start_controls_section(
			'section_style',
			[
				'label' => esc_html__( 'سبک', 'ecademy-toolkit' ),
				'tab' => Controls_Manager::TAB_STYLE,
			]
        );

            $this->add_control(
                'title_color',
                [
                    'label' => esc_html__( 'رنگ عنوان', 'ecademy-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .single-events-box .content h3 a, .single-events-box-item h3 a, .events-box .content h3 a' => 'color: {{VALUE}}',
                    ],
                ]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'title_typography',
                    'label' => __( ' عنوان تایپوگرافی', 'ecademy-toolkit' ),
                    'scheme' => Core\Schemes\Typography::TYPOGRAPHY_1,
                    'selector' => '{{WRAPPER}} .single-events-box .content h3, .single-events-box-item h3, .events-box .content h3',
                ]
            );

            $this->add_control(
                'top_title_color',
                [
                    'label' => esc_html__( 'موقعیت رنگ', 'ecademy-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .single-events-box .content .location, .single-events-box-item .location, .events-box .content .location' => 'color: {{VALUE}}',
                    ],
                ]
            );

            $this->add_group_control(
                Group_Control_Typography::get_type(),
                [
                    'name' => 'top_title_typography',
                    'label' => __( 'تایپوگرافی مکان', 'ecademy-toolkit' ),
                    'scheme' => Core\Schemes\Typography::TYPOGRAPHY_1,
                    'selector' => '{{WRAPPER}} .single-events-box .content .location, .single-events-box-item .location,  .events-box .content .location',
                ]
            );

            $this->add_control(
                'date_bg',
                [
                    'label' => esc_html__( 'رنگ پس زمینه تاریخ', 'ecademy-toolkit' ),
                    'type' => Controls_Manager::COLOR,
                    'selectors' => [
                        '{{WRAPPER}} .single-events-box-item .image .date, .single-events-box .image .date' => 'background-color: {{VALUE}}',
                    ],
                ]
            );

        $this->end_controls_section();

    }

	protected function render() {

        $settings = $this->get_settings_for_display();

        global $ecademy_opt;
		if( isset( $ecademy_opt['enable_lazyloader'] ) ):
			$is_lazyloader = $ecademy_opt['enable_lazyloader'];
		else:
			$is_lazyloader = true;
		endif;

        $cat_item = $settings['tp_event_category'];

        $ecademy_event_categories = get_terms('tp_event_category');

        $args_options = [];
        foreach ($cat_item as $key => $cat):
            if( !$cat['cat_name'] == '' ) {
                $args_options[] = get_term_by('slug', $cat['cat_name'], 'tp_event_category')->term_id;
            }
        endforeach;

        $event_array = new \WP_Query( array('posts_per_page' => $settings['count'], 'post_type' => 'tp_event', 'order' => $settings['order'], 'tax_query' => array( array( 'taxonomy' => 'tp_event_category', 'terms' => $args_options, ) ) ) );
        ?>

        <?php
        if( $settings['style'] == '1' ):
            if( $settings['all_text'] != '' ) {
                $all = $settings['all_text'];
            }else {
                $all = 'All';
            }
        ?>
            <div class="events-area pt-100 pb-70">
                <div class="container">
                    <div class="shorting-menu shorting-menu-style-two">
                        <button class="filter active" data-filter="all"><?php echo esc_attr($all); ?></button>
                        <?php
                        foreach ( $cat_item as $key => $cat ):
                            if( !$cat['cat_name'] == '' ) {
                                $term = get_term_by('slug', $cat['cat_name'], 'tp_event_category');
                                ?>
                                <button class="filter" data-filter=".<?php echo esc_attr($term->slug); ?>"><?php echo esc_html($cat['cat_name']); ?></button>
                                <?php
                            }
                        endforeach;
                        ?>
                    </div>

                    <div class="shorting" id="MixItUpD91DCD">
                        <div class="row">
                            <?php
                                while($event_array->have_posts()): $event_array->the_post();
                                $idd = get_the_ID();
                                $terms = wp_get_post_terms(get_the_ID(), 'tp_event_category');

                                $output = array();
                                if ($terms) {
                                    foreach ($terms as $term) {
                                        $output[] = $term->slug ;
                                        $id[] = $term->term_id ;
                                    }
                                }
                                ?>
                                <div class="col-lg-4 col-sm-6 col-md-6 mix <?php echo join( ' ', $output ); ?>">
                                    <div class="single-events-box">
                                        <div class="image">
                                            <a href="<?php the_permalink(); ?>" class="d-block">
                                                <?php the_post_thumbnail( 'ecademy_default_thumb' ); ?>
                                            </a>
                                            <?php
                                            $date_start = get_post_meta( get_the_ID(), 'tp_event_date_start', true ) ? strtotime( get_post_meta( get_the_ID(), 'tp_event_date_start', true ) ) : time();
                                            $date_string = date_i18n( get_option( 'date_format' ), $date_start ); ?>
                                            <span class="date"><?php echo esc_html( $date_string ); ?></span>
                                        </div>

                                        <div class="content">
                                            <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                            <span class="location"><i class="bx bx-map"></i><?php echo esc_html( get_field( 'event_location' ) ); ?></span>
                                        </div>
                                    </div>
                                </div>
                            <?php endwhile; ?>
                            <?php wp_reset_query(); ?>
                        </div>
                    </div>
                </div>
            </div>
        <?php endif; ?>

        <?php if( $settings['style'] == '2' ): ?>
            <div class="container">
                <div class="row">
                    <?php
                    while($event_array->have_posts()): $event_array->the_post();
                        $idd = get_the_ID();
                        $terms = wp_get_post_terms(get_the_ID(), 'tp_event_category');

                        $output = array();
                        if ($terms) {
                            foreach ($terms as $term) {
                                $output[] = $term->slug ;
                                $id[] = $term->term_id ;
                            }
                        }
                        ?>
                        <div class="col-lg-4 col-sm-6 col-md-6">
                            <div class="single-events-box">
                                <div class="image">
                                    <a href="<?php the_permalink(); ?>" class="d-block">
                                        <?php the_post_thumbnail( 'ecademy_default_thumb' ); ?>
                                    </a>
                                    <?php
                                    $date_start = get_post_meta( get_the_ID(), 'tp_event_date_start', true ) ? strtotime( get_post_meta( get_the_ID(), 'tp_event_date_start', true ) ) : time();
                                    $date_string = date_i18n( get_option( 'date_format' ), $date_start ); ?>
                                    <span class="date"><?php echo esc_html( $date_string ); ?></span>
                                </div>

                                <div class="content">
                                    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                    <span class="location"><i class="bx bx-map"></i><?php echo esc_html( get_field( 'event_location' ) ); ?></span>
                                </div>
                            </div>
                        </div>
                    <?php endwhile; ?>
                    <?php wp_reset_query(); ?>
                </div>
            </div>
        <?php endif; ?>

        <?php if( $settings['style'] == '3' ): ?>
            <div class="container">
                <div class="row">
                    <?php
                    while($event_array->have_posts()): $event_array->the_post();
                        $idd = get_the_ID();
                        $terms = wp_get_post_terms(get_the_ID(), 'tp_event_category');

                        $output = array();
                        if ($terms) {
                            foreach ($terms as $term) {
                                $output[] = $term->slug ;
                                $id[] = $term->term_id ;
                            }
                        }
                        ?>
                        <div class="col-lg-4 col-md-6">
                            <div class="single-events-box-item">
                                <div class="image">
                                    <a href="<?php the_permalink(); ?>" class="d-block">
                                        <?php the_post_thumbnail( 'ecademy_default_thumb' ); ?>
                                    </a>
                                    <?php

                                    $date_start = get_post_meta( get_the_ID(), 'tp_event_date_start', true ) ? strtotime( get_post_meta( get_the_ID(), 'tp_event_date_start', true ) ) : time();
                                    $date_string = date_i18n( get_option( 'date_format' ), $date_start ); ?>
                                    <span class="date"><?php echo esc_html( $date_string ); ?></span>
                                </div>

                                <div class="content">
                                    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                    <span class="location"><i class="bx bx-map"></i><?php echo esc_html( get_field( 'event_location' ) ); ?></span>
                                </div>
                            </div>
                        </div>
                    <?php endwhile; ?>
                    <?php wp_reset_query(); ?>
                </div>
            </div>
        <?php endif; ?>

        <?php if( $settings['style'] == '4' ): ?>
            <div class="container">
                <div class="row">
                    <?php
                        $i = 1;
                    while($event_array->have_posts()): $event_array->the_post();
                        $idd = get_the_ID();
                        $terms = wp_get_post_terms(get_the_ID(), 'tp_event_category');

                        $output = array();
                        if ($terms) {
                            foreach ($terms as $term) {
                                $output[] = $term->slug ;
                                $id[] = $term->term_id ;
                            }
                        }
                        ?>
                        <div class="col-lg-6 col-md-12 col-sm-6">
                            <div class="events-box">
                                <div class="row m-0">
                                    <div class="col-lg-4 col-md-5 p-0">
                                        <div class="image" style="background-image:url(<?php echo get_the_post_thumbnail_url(); ?>);">
                                            <?php the_post_thumbnail( 'ecademy_default_thumb' ); ?>
                                        </div>
                                    </div>

                                    <div class="col-lg-8 col-md-7 p-0">
                                        <div class="content">
                                            <div class="date">
                                                <?php if( $i < 5 ): ?>
                                                    <?php if( $is_lazyloader == true ): ?>
                                                        <img sm-src="<?php echo get_template_directory_uri() ?>/assets/img/rectangle<?php echo $i ?>.png" alt="<?php the_title(); ?>">
                                                    <?php else: ?>
                                                        <img src="<?php echo get_template_directory_uri() ?>/assets/img/rectangle<?php echo $i ?>.png" alt="<?php the_title(); ?>">
                                                    <?php endif; ?>
                                                <?php else: ?>
                                                    <?php if( $is_lazyloader == true ): ?>
                                                        <img sm-src="<?php echo get_template_directory_uri() ?>/assets/img/rectangle<?php echo rand(1,4); ?>.png" alt="<?php the_title(); ?>">
                                                    <?php else: ?>
                                                        <img src="<?php echo get_template_directory_uri() ?>/assets/img/rectangle<?php echo rand(1,4); ?>.png" alt="<?php the_title(); ?>">
                                                    <?php endif; ?>
                                                <?php endif; ?>
                                                <?php
                                                $date_start = get_post_meta( get_the_ID(), 'tp_event_date_start', true ) ? strtotime( get_post_meta( get_the_ID(), 'tp_event_date_start', true ) ) : time();
                                                $date_string = date_i18n( get_option( 'date_format' ), $date_start ); ?>
                                                <span class="date"><?php echo esc_html( $date_string ); ?></span>
                                            </div>
                                            <h3 class="font-weight-black"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                            <p><?php the_excerpt(); ?></p>
                                            <span class="location"><i class="bx bx-map"></i><?php echo esc_html( get_field( 'event_location' ) ); ?></i></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php ++$i; endwhile; ?>
                    <?php wp_reset_query(); ?>
                </div>
            </div>
        <?php endif; ?>
        <?php
	}


}

Plugin::instance()->widgets_manager->register( new eCademy_Events );