Sindbad~EG File Manager

Current Path : /home/xiedrke/entrepot/wp-content/themes/realpro/elementor/widgets/
Upload File :
Current File : /home/xiedrke/entrepot/wp-content/themes/realpro/elementor/widgets/agent-list.php

<?php

use RealPress\Models\UserModel;
use RealPress\Helpers\User;
use RealPress\Helpers\General;

use Elementor\Group_Control_Border;

if (!defined('ABSPATH')) {
    exit;
}

class Elementor_Realpro_Agent_List extends \Elementor\Widget_Base {
    public function get_name() {
        return 'realpro-agent-list';
    }

    public function get_title() {
        return esc_html__('Realpro: Agents List', 'realpro');
    }

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

    public function get_categories() {
        return ['realpro'];
    }

    public function get_base() {
        return basename(__FILE__, '.php');
    }

    protected function register_controls() {
        $this->start_controls_section(
            'content',
            [
                'label' => esc_html__('Agents', 'realpro')
            ]
        );

        $this->add_control(
            'order',
            array(
                'label'   => esc_html__('Order', 'realpro'),
                'type'    => \Elementor\Controls_Manager::SELECT,
                'options' => array(
                    'asc'  => esc_html__('ASC', 'realpro'),
                    'desc' => esc_html__('DESC', 'realpro'),
                ),
                'default' => 'asc',
            )
        );
        $this->add_control(
            'number_posts',
            array(
                'label'   => esc_html__('The number of Posts', 'realpro'),
                'default' => '4',
                'type'    => \Elementor\Controls_Manager::NUMBER,
            )
        );

        $this->add_control(
			'rp_columns',
			[
				'label' => esc_html__( 'Columns', 'realpro' ),
				'type' => \Elementor\Controls_Manager::SELECT,
				'options' => array(
					'1' => '1',
					'2' => '2',
					'3' => '3',
					'4' => '4',
				),

                'default' => '3',
				
				'selectors' => [
					'{{WRAPPER}}' => '--el-realpro-agent__inner: {{VALUE}};',
				],
			]
		);
        
        $this->end_controls_section();
    }

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

        $query_args = array(
            'role'           => 'realpress-agent',
            'number'      => $settings['number_posts'],
            'order'               => ('asc' == $settings['order']) ? 'asc' : 'desc',
            'ignore_sticky_posts' => true,
        );

        $the_query = new \WP_User_Query($query_args);

        $agents = $the_query->get_results();

        $class            = 'el-realpro-agent';
        $class_inner      = 'el-realpro-agent__inner slick';
        $class_item       = 'el-realpro-agent__article';

        

        $rp_columns = isset($settings['rp_columns']) ? $settings['rp_columns'] : '3';

        if($settings['number_posts'] && $rp_columns ) {
            if($settings['number_posts'] > $rp_columns ) {
                $class_inner .= ' slick';
            }
        }

        $value_slider = 'false';

        $hiden_nav_mobile = '';
        if (!empty($agents)) {
            ?>
                <div class="<?php echo esc_attr($class); ?>">
                    <div class="<?php echo esc_attr($class_inner); ?>" data-show="<?php echo esc_attr($rp_columns); ?>">

                        <?php 
                            if(is_rtl()) {
                                $value_slider = 'true';
                            } 
                        ?>
                        <?php
                        foreach ($agents as $agent) {
                            $this->render_agent($settings, $agent, $class_item);
                        }
                        ?>
                    </div>
                </div>
            <?php
        }

        wp_reset_postdata();
    }

    protected function render_agent($settings, $agent, $class_item) {
        $agent_id       =  $agent->ID;
        $user_meta_data          = UserModel::get_user_meta_data( $agent_id);
        $office_number           = $user_meta_data['user_profile:fields:office_phone_number'];
        $mobile_number           = $user_meta_data['user_profile:fields:mobile_number'];
        $license                 = $user_meta_data['user_profile:fields:license'];
		$tax_number              = $user_meta_data['user_profile:fields:tax_number'];
        $address                 = $user_meta_data['user_profile:fields:address'];
        $email                   = UserModel::get_field( $agent_id, 'user_email' );

        $this->render_text_header($class_item);
        $this->render_agent_thumbnail($settings, $agent_id);
        $this->render_agent_content();
        $this->render_agent_name($agent_id);
        $this->render_meta_data_licence($license);
        $this->render_meta_data_phone($mobile_number);
        $this->render_text_footer();
    }

    protected function render_agent_name($agent_id) {
        $user_url = get_author_posts_url( $agent_id );
        ?>
        <div class="el-realpro-agent-name">
			<h4><a href="<?php echo esc_url( $user_url ); ?>"><?php echo esc_html( UserModel::get_field( $agent_id, 'display_name' ) ); ?></a></h4>
		</div>
        <?php
    }

    protected function render_agent_position($user_meta_data) {
        $position        = $user_meta_data['user_profile:fields:position'];
        if(!empty($position)){
            ?>
            <div class="el-realpro-agent-position">
                <?php echo esc_html( $position ); ?>
            </div>
            <?php
        }
    }

    protected function render_agent_company($user_meta_data) {
        $company_name            = $user_meta_data['user_profile:fields:company_name'];
        $company_url             = $user_meta_data['user_profile:fields:company_url'];

        if ( ! empty( $company_name ) && ! empty( $company_url ) ) {
			?>
			<div class="el-realpro-agent-company">
				<?php echo esc_html__( 'Company Agent at ', 'realpro' ); ?>
				<a target="_blank" href="<?php echo esc_url( $company_url ); ?>"><?php echo esc_html( $company_name ); ?></a>
			</div>
			<?php
		}
    }

    protected function render_agent_description($agent_id) {
        $description    = get_the_author_meta( 'description', $agent_id );
        if(!empty($description)){
            ?>
			<div class="el-realpro-agent-description">
                <p><?php echo esc_html( $description ); ?></p>
            </div>
            <?php
        }
    }

    protected function render_agent_thumbnail($settings, $agent_id ) {
        $social_networks = User::get_social_networks( $agent_id );
        $avatar_url              = UserModel::get_user_avatar_url( $agent_id, 'full' );
        $user_url                = get_author_posts_url( $agent_id );

		if ( ! empty( $avatar_url ) ) {
			?>
                <div class="el-realpro-agent-avatar">
                    <a href="<?php echo esc_url( $user_url ); ?>">
                        <img src="<?php echo esc_url( $avatar_url ); ?>" alt="#agent-avatar">
                    </a>
                </div>
			<?php
		}
    }

    protected function render_agent_content() {
        ?>
        </div><div class="el-realpro-agent-body">
        <?php
    }

    protected function render_text_header($class_item) {
		?>
		<div class="el-realpro-agent-item <?php echo esc_attr($class_item); ?>">
            <div class="el-realpro-agent-wrapper">
			    <div class="el-realpro-agent-header">
		<?php
	}

    protected function render_text_footer() {
		?>
			</div></div></div>
		<?php
	}

    protected function render_meta_data_phone( $mobile_number) {
        ?>
            <div class="el-realpro-agent-mobile">
                <span><?php echo esc_html__( 'Mobile:', 'realpro' ); ?></span>
                <a href="tel:<?php echo esc_attr( $mobile_number ); ?>"><?php echo esc_html( $mobile_number ); ?></a>
            </div>      
        <?php
    }

    protected function render_meta_data_licence($license) {
        ?>
            <div class="el-realpro-agent-license">
                <span><?php echo esc_html__( 'Agent License:', 'realpro' ); ?></span>
                <span class="info"><?php echo esc_html( $license ); ?></span>
            </div>
        <?php
    }
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists