<?php
global $post;
function display_agent_box( $args ) {
global $post;
?>
<div class="agent-detail clearfix">
<div class="left-box">
<?php
if ( isset( $args['agent_title_text'] ) && ! empty( $args['agent_title_text'] ) ) {
?><h3 id="contact-us"><?php echo esc_html( $args['agent_title_text'] ); ?></h3><?php
}
if ( isset( $args['display_author'] ) && ( $args['display_author'] ) ) {
if ( isset( $args['profile_image_id'] ) && ( 0 < $args['profile_image_id'] ) ) {
?>
<figure><?php echo wp_get_attachment_image( $args['profile_image_id'], 'agent-image' ); ?></figure>
<?php
} elseif ( isset( $args['agent_email'] ) ) {
?>
<figure><?php echo get_avatar( $args['agent_email'], '210' ); ?></figure>
<?php
}
} else {
if ( isset( $args['agent_id'] ) && has_post_thumbnail( $args['agent_id'] ) ) {
?>
<figure>
<?php echo get_the_post_thumbnail( $args['agent_id'], 'image' ); ?>
</figure>
<?php
}
}
?>
<p><?php
echo $args['agent_description'];
?>
<br/>
<?php
if ( isset( $args['display_author'] ) && ( $args['display_author'] ) ) {
?>
<a class="real-btn" href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php echo esc_html( $button_label ); ?></a><?php
} else {
}
?></p>
</div>
<?php
if ( isset( $args['agent_email'] ) && ! empty( $args['agent_email'] ) ) {
$agent_form_id = 'agent-form-id';
if ( isset( $args['agent_id'] ) ) {
$agent_form_id .= $args['agent_id'];
}
?>
<div class="contact-form">
<id="contact-us">
<h3><?php _e( 'contact us', 'framework' ); ?></h3>
<form id="<?php echo esc_attr( $agent_form_id ); ?>" class="agent-form contact-form-small" method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
<?php _e('Name *', 'framework'); ?><input type="text" name="name" placeholder="<?php _e( '', 'framework' ); ?>" class="required" title="<?php _e( '* Please provide your name', 'framework' ); ?>">
<?php _e('Email *', 'framework'); ?><input type="text" name="email" placeholder="<?php _e( '', 'framework' ); ?>" class="email required" title="<?php _e( '* Please provide valid email address', 'framework' ); ?>">
<?php _e('Phone Number', 'framework'); ?><input type="text" name="phone" placeholder="<?php _e( '', 'framework' ); ?>">
<?php _e('Message *', 'framework'); ?><textarea name="message" class="required" placeholder="<?php _e( '', 'framework' ); ?>" title="<?php _e( '* Please provide your message', 'framework' ); ?>"></textarea>
<?php
$is_gdpr_enabled = inspiry_is_gdpr_enabled();
if ( $is_gdpr_enabled ) {
$gdpr_agreement_text = inspiry_gdpr_agreement_content();
if ( ! empty( $gdpr_agreement_text ) ) {
?>
<p class="gdpr-agreement clearfix">
<?php
$gdpr_agreement_label = inspiry_gdpr_agreement_content( 'label' );
$gdpr_agreement_val_msg = inspiry_gdpr_agreement_content( 'validation-message' );
if ( ! empty( $gdpr_agreement_label ) ) {
?>
<span class="gdpr-checkbox-label"><?php echo esc_html( $gdpr_agreement_label ); ?>
<span class="required-label">*</span></span>
<?php
}
?>
<input type="checkbox" id="inspiry-gdpr-<?php echo esc_attr( $agent_form_id ); ?>" class="required" name="gdpr" title="<?php echo esc_attr( $gdpr_agreement_val_msg ); ?>" value="<?php echo strip_tags( $gdpr_agreement_text ); ?>">
<label for="inspiry-gdpr-<?php echo esc_attr( $agent_form_id ); ?>"><?php echo $gdpr_agreement_text; ?></label>
</p>
<p><?php _e( '* Commen fields', 'framework' ); ?></p>
<?php
}
}
get_template_part( 'common/google-reCAPTCHA/google-reCAPTCHA' );
?>
<input type="hidden" name="nonce" value="<?php echo wp_create_nonce( 'agent_message_nonce' ); ?>"/>
<input type="hidden" name="target" value="<?php echo antispambot( $args['agent_email'] ); ?>">
<input type="hidden" name="action" value="send_message_to_agent"/>
<input type="hidden" name="property_id" value="<?php echo esc_attr(get_the_ID()) ?>">
<input type="hidden" name="property_title" value="<?php echo esc_attr( get_the_title( $post->ID ) ); ?>"/>
<input type="hidden" name="property_permalink" value="<?php echo esc_url_raw( get_permalink( $post->ID ) ); ?>"/>
<input type="submit" value="<?php _e( 'Send Message', 'framework' ); ?>" name="submit" class="submit-button real-btn">
<div class="clearfix form-separator"></div>
<div class="error-container"></div>
<div class="message-container"></div>
</form>
</div>
<script type="text/javascript">
(function( $ ) {
"use strict";
if( jQuery().validate && jQuery().ajaxSubmit ) {
var agentForm = $( '#<?php echo esc_attr( $agent_form_id ); ?>' );
var submitButton = agentForm.find( '.submit-button' ),
ajaxLoader = agentForm.find( '.ajax-loader' ),
messageContainer = agentForm.find( '.message-container' ),
errorContainer = agentForm.find( ".error-container" );
agentForm.validate( {
errorLabelContainer : errorContainer, submitHandler : function( form ) {
$( form ).ajaxSubmit( {
beforeSubmit : function() {
submitButton.attr( 'disabled', 'disabled' );
ajaxLoader.fadeIn( 'fast' );
messageContainer.fadeOut( 'fast' );
errorContainer.fadeOut( 'fast' );
}, success : function( ajax_response, statusText, xhr, $form ) {
var response = $.parseJSON( ajax_response );
ajaxLoader.fadeOut( 'fast' );
submitButton.removeAttr( 'disabled' );
if( response.success ) {
$form.resetForm();
messageContainer.html( response.message ).fadeIn( 'fast' );
if( typeof inspiryResetReCAPTCHA == 'function' ) {
inspiryResetReCAPTCHA();
}
} else {
errorContainer.html( response.message ).fadeIn( 'fast' );
}
}
} );
}
} );
}
})( jQuery );
</script>
<?php
}
?>
</div>
<?php
}
$display_agent_info = get_option( 'theme_display_agent_info' );
$agent_display_option = get_post_meta( $post->ID, 'PAGE_agent_display_option', true );
if ( ( $display_agent_info == 'true' ) && ( $agent_display_option != "none" ) ) {
if ( $agent_display_option == "my_profile_info" ) {
$profile_args = array();
$profile_args['display_author'] = true;
$profile_args['agent_title_text'] = __( 'Submitted by', 'framework' ) . " " . get_the_author_meta( 'display_name' );
$profile_args['profile_image_id'] = intval( get_the_author_meta( 'profile_image_id' ) );
$profile_args['agents_count'] = 1;
$profile_args['agent_mobile'] = get_the_author_meta( 'mobile_number' );
$profile_args['agent_whatsapp'] = get_the_author_meta( 'whatsapp_number' );
$profile_args['agent_office_phone'] = get_the_author_meta( 'office_number' );
$profile_args['agent_office_fax'] = get_the_author_meta( 'fax_number' );
$profile_args['agent_email'] = get_the_author_meta( 'user_email' );
$profile_args['agent_description'] = get_framework_custom_excerpt( get_the_author_meta( 'description' ), 50 );
display_agent_box( $profile_args );
} else {
$property_agents = get_post_meta( $post->ID, 'PAGE_agents' );
$property_agents = array_filter( $property_agents, function( $v ) {
return ( $v > 0 );
} );
$property_agents = array_unique( $property_agents );
if ( ! empty( $property_agents ) ) {
$agents_count = count( $property_agents );
foreach ( $property_agents as $agent ) {
if ( 0 < intval( $agent ) ) {
$agent_args = array();
$agent_args['agent_id'] = intval( $agent );
$agent_args['agents_count'] = $agents_count;
$agent_args['agent_title_text'] = __( '', 'framework' ) . " " . get_the_title( $agent_args['agent_id'] );
$agent_args['agent_mobile'] = get_post_meta( $agent_args['agent_id'], 'PAGE_mobile_number', true );
$agent_args['agent_office_phone'] = get_post_meta( $agent_args['agent_id'], 'PAGE_office_number', true );
$agent_args['agent_whatsapp'] = get_post_meta( $agent_args['agent_id'], 'PAGE_whatsapp_number', true );
$agent_args['agent_office_fax'] = get_post_meta( $agent_args['agent_id'], 'PAGE_fax_number', true );
$agent_args['agent_email'] = get_post_meta( $agent_args['agent_id'], 'PAGE_agent_email', true );
$temp_agent_excerpt = get_post_field( 'post_excerpt', $agent_args['agent_id'] );
if ( empty( $temp_agent_excerpt ) || is_wp_error( $temp_agent_excerpt ) ) {
$agent_args['agent_excerpt'] = get_post_field( 'post_content', $agent_args['agent_id'] );
} else {
$agent_args['agent_excerpt'] = $temp_agent_excerpt;
}
$agent_args['agent_description'] = get_framework_custom_excerpt( $agent_args['agent_excerpt'], 205 );
display_agent_box( $agent_args );
}
}
}
}
}