Sindbad~EG File Manager

Current Path : /home/xiedrke/entrepot/wp-content/themes/realpro/inc/widgets/
Upload File :
Current File : /home/xiedrke/entrepot/wp-content/themes/realpro/inc/widgets/contact-summary.php

<?php

use RealPress\Models\PropertyModel;
use RealPress\Models\PropertyMetaModel;
use RealPress\Helpers\Template;
use RealPress\Helpers\Validation;
use RealPress\Models\UserModel;
use RealPress\Helpers\Page;
use RealPress\Helpers\SourceAsset;
use RealPress\Helpers\Settings;
use RealPress\Helpers\Config;

class WP_Realpro_Widget_Contact_Summary extends WP_Widget {

	private $settings;

	function __construct() {
		$widget_ops = array( 'classname' => 'realpro_widget_contact_summary', 'description' => esc_html__( "Realpro contact summary option.", "realpro" ) );
		parent::__construct( 'realpro-contact-summary', esc_html__( '[Realpro] Contact Summary', 'realpro' ), $widget_ops );
		$this->alt_option_name = 'realpro_widget_contact_summary';
		$this->settings = Config::instance()->get( 'contact-form', 'widgets' );
	}

	public function form( $instance ) {
		$title = isset( $instance['title'] ) ? esc_html__( $instance['title'], 'realpro' ) : esc_html__( 'Contact with us now !', 'realpro' );
		$cc_admin = isset( $instance['cc_admin'] ) ? $instance['cc_admin'] : '';
		?>

		<p>
			<label for="<?php echo esc_html( $this->get_field_id( 'title' ) ); ?>"><?php echo esc_html( 'Title', 'realpro' ); ?></label>
			<input class="widefat" id="<?php echo esc_html( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_html( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"/>
		</p>
		<p>
			<input class="widefat" name="cc-admin" type="checkbox" value="<?php echo esc_attr( $cc_admin ); ?>"/>
			<label for="cc-admin"><?php echo esc_html( 'CC admin email', 'realpro' ); ?></label>
		</p>
		<?php
	}

	public function widget( $args, $instance ) {

		ob_start();
		echo wp_kses_post( $args['before_widget'] );
		$data = PropertyModel::get_data( get_the_ID() );

		if ( ! Page::is_property_single_page() ) {
			return;
		}

		global $post;
		$show_custom_field   = false;
		$user_meta_data      = array();
		$agent_custom_fields = array();
		$agent      = PropertyMetaModel::instance( $post->ID )->get_agent_info();

		if ( empty( $agent['enable'] ) ) {
			return;
		}
		$user_id         = $agent['user_id'];
		$agent_form_info = $agent['info'];
		if ( $agent_form_info === 'show_custom_field' ) {
			$show_custom_field = true;
			if ( empty( $agent['custom_fields'] ) ) {
				return;
			}
			$agent_custom_fields = $agent['custom_fields'];
		} else {
			$user_meta_data = UserModel::get_user_meta_data( $user_id );
		}

		$mobile_number = !empty($user_meta_data['user_profile:fields:mobile_number']) ? $user_meta_data['user_profile:fields:mobile_number'] : '';

		?>
		<div class="realpro-summary">
			<div class="realpress-property-title">
				<h4><i class="rp-star"></i><?php echo esc_html( $data['title'] ); ?></h4>
			</div>
			<?php
				Template::instance()->get_frontend_template_type_classic( 'single-property/section/header/left/status-rating.php', compact( 'data' ) );
				Template::instance()->get_frontend_template_type_classic( 'single-property/section/header/left/address-date.php', compact( 'data' ) );
			?>
			<div class="realpro-prices-area">
				<?php
					Template::instance()->get_frontend_template_type_classic( 'shared/property-list/property-item/price.php', compact( 'data' ) );
					Template::instance()->get_frontend_template_type_classic( 'shared/single-property/area-size.php', compact( 'data' ) );
				?>
			</div>
		</div>
		<?php

		if ( ! empty( $instance['title'] ) ) {
			echo wp_kses_post($args['before_title']) . esc_html( $instance['title'] ) . wp_kses_post($args['after_title']);
		}

		if ( $show_custom_field === true ) {
			?>
			<ul class=" realpress-agent-custom-fields">
				<?php
				foreach ( $agent_custom_fields as $agent_custom_field ) {
					?>
					<li>
						<div><?php echo esc_html( $agent_custom_field['label'] ); ?></div>
						<div><?php echo esc_html( $agent_custom_field['value'] ); ?></div>
					</li>
					<?php
				}
				?>
			</ul>
			<?php
		} else {
			?>
			<div class="realpro-contact">
				<div class="realpro-contact-head">
					<?php
					$avatar_url   = UserModel::get_user_avatar_url( $user_id );
					$display_name = UserModel::get_field( $user_id, 'display_name' );
					if ( ! empty( $avatar_url ) ) {
						?>
						<div class="realpro-contact-image">
							<img src="<?php echo esc_url_raw( $avatar_url ); ?>"
								alt="<?php echo esc_attr( $display_name ); ?>">
						</div>
						<?php
					}
					?>
					<div class="realpro-contact-info">
						<div class="realpro-contact-name"><?php echo esc_html( $display_name ); ?></div>
						<?php
							if ( $mobile_number ) {
								?>
									<div class="realpro-contact-mobile"><?php echo esc_html($mobile_number, 'realpro'); ?></div>
								<?php
							}
						?>
					</div>
				</div>
				<div class="realpress-contact-link">
					<?php
						if($mobile_number) {
							?>
								<a href="<?php echo esc_url_raw( 'tel:' . $mobile_number ); ?>" class="call"><span class="textlink"><?php echo esc_html('Call now', 'realpro' ); ?></span></a>
							<?php
						}
					?>
					<span class="mess"><span class="textbtn"><?php echo esc_html('Message', 'realpro' ); ?></span></span>
				</div>
			</div>
			<?php
		}

		$term_args = $instance;
		unset( $term_args['title'] );
		$data = array(
			'cc_admin' => $term_args['cc_admin'] ?? '',
		);

		?>
		<div class="realpro-form-popup">
			<div class="realpro-popup-content">
				<div class="head">
					<h4 class="title"><?php echo esc_html__('Send a mesage', 'realpro'); ?></h4>
					<i class="rp-closes"></i>
				</div>
				<?php Template::instance()->get_frontend_template_type_classic( 'widgets/contact-form.php', compact( 'data' ) ); ?>

			</div>
			<div class="thim-pbg-overlay"></div>
		</div>
		<?php

		echo wp_kses_post( $args['after_widget'] );
		$content = ob_get_clean();
		echo wp_kses_post($content);
	}

	public function update( $new_instance, $old_instance ) {
		$instance = $old_instance;

		foreach ( $new_instance as $key => $value ) {
			$field            = $this->settings[ $key ];
			$sanitize         = $field['sanitize'] ?? 'text';
			$value            = Validation::sanitize_params_submitted( $value, $sanitize );
			$instance[ $key ] = $value;
		}

		return $instance;
	}
}

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