| Server IP : 104.129.129.72 / Your IP : 216.73.216.229 Web Server : LiteSpeed System : Linux 123answers 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64 User : answe8064 ( 1002) PHP Version : 8.2.28 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/123answers.ca/public_html/winnipeg/wp-content/themes/directorytheme/ |
Upload File : |
<?php acf_form_head();
/**
* Template Name: Contact
*/
get_header();
/* this code is used for if captcha value in field in backend
Screenshort : https://prnt.sc/1ubuu9e
*/
$enable_captcha_key = get_option('options_recaptch_field', true);
$captcha_site_key = get_option('options_form_recaptcha_site_key', true);
?>
<!-- Check validation of form -->
<script>
function isEmail(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
}
function submitUserForm() {
var email = jQuery('.acf-field-email input[type=email]').val();
var contact_title = jQuery('input#acf-_post_title').val();
if( contact_title == '' ){
jQuery('.acf-error-message').first().html('<span style="color:red;">Name field is required.</span>');
jQuery('.acf-error-message').first().show();
return false;
} else {
jQuery('.acf-error-message').first().hide();
}
if(!isEmail(email)){
jQuery('.acf-field-email .acf-error-message').show();
jQuery('.acf-field-email .acf-error-message').html('<span style="color:red;">Email field is required.</span>');
return false;
} else {
jQuery('.acf-field-email .acf-error-message').hide();
}
<?php
$contact_captcha_key = get_field('captcha_contact','option');
if($enable_captcha_key == '1' && $contact_captcha_key == '1'){
if( !empty($captcha_site_key) ){ ?>
var response = grecaptcha.getResponse();
if( response.length == 0 ){
document.getElementById('g-recaptcha-error').innerHTML = '<span style="color:red;">This field is required.</span>';
return false;
}
return true;
function verifyCaptcha() {
document.getElementById('g-recaptcha-error').innerHTML = '';
}
<?php
}
} ?>
}
</script>
<script src='https://www.google.com/recaptcha/api.js' async defer></script>
<!-- This code is used for Banner section of page.
Scrrenshort : https://prnt.sc/1ubgrwf -->
<div id="page-banner" class="
<?php if(get_field('banner')) : ?>has-banner<?php endif; ?>"
style="background: <?php if(get_field('banner')) : ?>url('<?php the_field('banner'); ?>')
no-repeat
<?php the_field('bg_position'); ?>
transparent;
<?php endif; ?>;">
<div class="inner">
<h1><?php the_title(); ?></h1>
</div><!--inner-->
</div><!--page-banner-->
<div id="cp-container" class="cp-section">
<div class="inner">
<div class="full-content">
<?php
if (have_posts()):
while (have_posts()) : the_post(); ?>
<div class="entry contact_content">
<?php the_content(); ?>
</div>
<?php
endwhile;
endif;
$maichimp_enable = get_field('mailchimp_field', 'option');
$api_key = get_field('mailchimp_api_key', 'option');
$list_id = get_field('mailchimp_list_id', 'option');
$form_title = get_option('options_form_title',true);
$form_content = get_option('options_form_content',true);
$enable_phone = get_field('enable_phone','option');
$enable_subject = get_field('enable_subject','option');
$enable_message = get_field('message_field','option');
$form_button_text = get_option('options_form_button_text', true);
$btn_txt = !empty($form_button_text) ? $form_button_text : 'Submit Message';
function honeypot_validade ($req) {
if (!empty($req)) {
$honeypot_fields = [
"post_title_ohnohoney", "email_ohnohoney", "phone_ohnohoney", "subject_ohnohoney", "c_message_ohnohoney", "validate_email_ohnohoney"
];
foreach ($honeypot_fields as $field) {
if (isset($req[$field]) && !empty($req[$field])) {
return false;
}
}
}
return true;
}
if (honeypot_validade($_REQUEST)) {
$is_spammer = false;
}else{
$is_spammer = true;
}
if($is_spammer === false){
if(isset($_POST['Action']) && $_POST['Action'] == 'contact_inq'):
$my_post_arg = array(
'post_title' => sanitize_text_field(wp_strip_all_tags($_POST['acf']['_post_title'])),
'post_type' => 'contacts',
'post_status' => 'publish'
);
$id = wp_insert_post( $my_post_arg );
if(!empty($id)):
update_post_meta($id,'c_email', sanitize_text_field($_POST['acf']['field_5a56fd92872ea']));
update_post_meta($id,'_c_email', 'field_5a56fd92872ea');
update_post_meta($id,'c_phone', sanitize_text_field($_POST['acf']['field_5a56fd9f872eb']));
update_post_meta($id,'_c_phone', 'field_5a56fd9f872eb');
update_post_meta($id,'c_subject', sanitize_text_field($_POST['acf']['field_5a56fda9872ec']));
update_post_meta($id,'_c_subject', 'field_5a56fda9872ec');
update_post_meta($id,'c_message', sanitize_text_field($_POST['acf']['field_5a56fdb0872ed']));
update_post_meta($id,'_c_message', 'field_5a56fdb0872ed');
update_post_meta($id,'_validate_email', '');
update_post_meta($id,'__validate_email', '_validate_email');
$to = get_field('contact_notification', 'option');
if( $to == ""){
$to = get_bloginfo('admin_email');
}
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers = 'From: '. sanitize_text_field($_POST['acf']['field_5a56fd92872ea']) . "\r\n" .'Reply-To: ' . sanitize_text_field($_POST['acf']['field_5a56fd92872ea']) . "\r\n";
$headers = array('Content-Type: text/html; charset=UTF-8','Reply-To: <'.sanitize_text_field($_POST['acf']['field_5a56fd92872ea']).'>');
$subval = sanitize_text_field($_POST['acf']['field_5a56fda9872ec']);
$phnval = sanitize_text_field($_POST['acf']['field_5a56fd9f872eb']);
$msgval = sanitize_text_field($_POST['acf']['field_5a56fdb0872ed']);
$subt =($enable_subject=='1'? $subval : "");
$phnt =($enable_phone=='1'? $phnval : "");
$mesgt =($enable_message=='1'? $msgval : "");
$body .= 'Below are the details of Contact'. "\r\n";
$body .= 'Name : '.sanitize_text_field($_POST['acf']['_post_title']). "\r\n";
$body .= 'Email : '.sanitize_text_field($_POST['acf']['field_5a56fd92872ea']). "\r\n\r\n";
$new = get_option('options_contact_notification', true);
if($subt != ''){
$body .= '<p>Subject : '.$subt. "</p>";
}
if($phnt != ''){
$body .= '<p>Phone : '.$phnt. "</p>";
}
if($mesgt != '' && strlen($mesgt) != 0){
$body .= '<p>Message : '.$mesgt. "</p>";
}
wp_mail(get_option('options_contact_notification', true), "Contact Request", $body, $headers);
if(isset($_POST['mailchimp_action']) && $_POST['mailchimp_action'] == 'mailchimpsubscribe'):
$id;
$email = get_post_meta( $id, 'c_email', true );
$fnm = get_the_title( $id );
$ph_no = get_post_meta( $id, 'c_phone', true );
$api_key = get_field('mailchimp_api_key', 'option');
$list_id = get_field('mailchimp_list_id', 'option');
$status = 'subscribed';
$mch_api = curl_init(); // initialize cURL connection
$data = array(
'apikey' => $api_key,
'email_address' => $email,
'status' => $status,
'merge_fields' => ['FNAME'=> $fnm]
);
curl_setopt($mch_api, CURLOPT_URL, 'https://' . substr($api_key,strpos($api_key,'-')+1) . '.api.mailchimp.com/3.0/lists/' . $list_id . '/members/' . md5(strtolower($data['email_address'])));
curl_setopt($mch_api, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Basic '.base64_encode( 'user:'.$api_key )));
curl_setopt($mch_api, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($mch_api, CURLOPT_RETURNTRANSFER, true); // return the API response
curl_setopt($mch_api, CURLOPT_CUSTOMREQUEST, 'PUT'); // method PUT
curl_setopt($mch_api, CURLOPT_TIMEOUT, 10);
curl_setopt($mch_api, CURLOPT_POST, true);
curl_setopt($mch_api, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($mch_api, CURLOPT_POSTFIELDS, json_encode($data) ); // send data in json
$result = curl_exec($mch_api);
endif;
/* start sendio functionality */
if(isset($_POST['sendio_subscribe']) && $_POST['sendio_subscribe'] == 'sandiosubscribe'):
$id;
$email = get_post_meta( $id, 'c_email', true );
$fnm = get_the_title( $id );
$ph_no = get_post_meta( $id, 'c_phone', true );
$sendio_contactid = get_field('sendio_contactid','option');
$sendio_formid = get_field('sendio_form_id','option');
if($sendio_contactid != '' && $sendio_formid != ''){
$url = 'https://sendiio.com/callbacks/subscription/lists';
$ch = curl_init($url);
$jsonData = array(
'name' => $fnm,
'email' => $email,
'Email' => $email,
'list'=> $sendio_contactid,
'form' => $sendio_formid
);
$jsonDataEncoded = json_encode($jsonData);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
}
endif;
/*sendio over*/
endif;
echo '<div class="alert alert-info text-center" role="alert">Thanks for contacting us! We will be in touch with you shortly.</div>';
endif;
}
if( $form_title == '1' || empty($form_title) ) {
echo '<h2 style="width: 100%;text-align: center;">' . __( "Contact Us", "directorytheme" ) . '</h2>';
} else {
/*printf( __( '<h2 style="width: 100%;text-align: center;"> %s </h2>', 'directorytheme' ),
$form_title
);*/
echo '<h2 style="width: 100%;text-align: center;">'.__( $form_title, "directorytheme" ).'</h2>';
}
?>
<!-- Conatct from
Screnshort : https://prnt.sc/1ubvo32 -->
<style>
.ohnohoney{
opacity: 0;
position: absolute;
top: 0;
left: 0;
height: 0;
width: 0;
z-index: -1;
}
</style>
<form method="post" name="contect_frm" id="contect_frm" action="" onsubmit="return submitUserForm();">
<div class="acf-error-message" style="display:none;"><p><?php echo __('Validation failed. 2 fields require attention', 'directorytheme'); ?></p><a href="#" class="acf-icon -cancel small"></a></div>
<div id="acf-form-data" class="acf-hidden">
</div>
<div class="acf-fields acf-form-fields -top">
<div class="acf-field acf-field-text acf-field--post-title" data-name="_post_title" data-type="text" data-key="_post_title" data-required="1">
<div class="acf-label"><label for="acf-_post_title"><?php echo __('Name:', 'directorytheme'); ?><span class="acf-required">*</span></label></div>
<div class="acf-input">
<div class="acf-input-wrap"><input type="text" id="acf-_post_title" name="acf[_post_title]" required="required"></div> </div>
<!-- H o n e y p o t -->
<div class="acf-input ohnohoney">
<div class="acf-input-wrap ohnohoney">
<input class="ohnohoney" autocomplete="off" type="text" id="post_title_ohnohoney" name="post_title_ohnohoney">
</div>
</div>
</div>
<div class="acf-field acf-field-email acf-field-5a56fd92872ea acf-error" data-name="c_email" data-type="email" data-key="field_5a56fd92872ea" data-required="1">
<div class="acf-label"><label for="acf-field_5a56fd92872ea"><?php echo __('Email:', 'directorytheme'); ?><span class="acf-required">*</span></label></div>
<div class="acf-input"><div class="acf-error-message" style="display:none;"><p><?php echo __('Email field is required.', 'directorytheme'); ?></p></div>
<div class="acf-input-wrap"><input type="email" id="acf-field_5a56fd92872ea" name="acf[field_5a56fd92872ea]" required="required"></div> </div>
<!-- H o n e y p o t -->
<div class="acf-input ohnohoney">
<div class="acf-input-wrap ohnohoney">
<input class="ohnohoney" type="email" id="email_ohnohoney" name="email_ohnohoney">
</div>
</div>
</div>
<?php if($enable_phone == '1' && !empty($enable_phone)): ?>
<div class="acf-field acf-field-text acf-field-5a56fd9f872eb" data-name="c_phone" data-type="text" data-key="field_5a56fd9f872eb" >
<div class="acf-label"><label for="acf-field_5a56fd9f872eb"><?php echo __('Phone:', 'directorytheme'); ?></label></div>
<div class="acf-input"><div class="acf-error-message" style="display:none;"><p><?php echo __('Phone number is required.', 'directorytheme'); ?></p></div>
<div class="acf-input-wrap"><input type="text" id="acf-field_5a56fd9f872eb" name="acf[field_5a56fd9f872eb]"></div> </div>
<!-- H o n e y p o t -->
<div class="acf-input ohnohoney">
<div class="acf-input-wrap ohnohoney">
<input class="ohnohoney" type="text" id="phone_ohnohoney" name="phone_ohnohoney">
</div>
</div>
</div>
<?php
endif;
if($enable_subject == '1'): ?>
<div class="acf-field acf-field-text acf-field-5a56fda9872ec" data-name="c_subject" data-type="text" data-key="field_5a56fda9872ec">
<div class="acf-label"><label for="acf-field_5a56fda9872ec"><?php echo __('Subject:', 'directorytheme'); ?></label></div>
<div class="acf-input"><div class="acf-error-message" style="display:none;"><p><?php echo __('Subject is required', 'directorytheme'); ?></p></div>
<div class="acf-input-wrap"><input type="text" id="acf-field_5a56fda9872ec" name="acf[field_5a56fda9872ec]"></div> </div>
<!-- H o n e y p o t -->
<div class="acf-input ohnohoney">
<div class="acf-input-wrap ohnohoney">
<input class="ohnohoney" type="text" id="subject_ohnohoney" name="subject_ohnohoney">
</div>
</div>
</div>
<?php
endif;
if($enable_message == '1'): ?>
<div class="acf-field acf-field-textarea acf-field-5a56fdb0872ed" data-name="c_message" data-type="textarea" data-key="field_5a56fdb0872ed">
<div class="acf-label"><label for="acf-field_5a56fdb0872ed"><?php echo __('Message:', 'directorytheme'); ?></label></div>
<div class="acf-input">
<div class="acf-error-message" style="display:none;"><p><?php echo __('Message is required', 'directorytheme'); ?></p></div>
<textarea id="acf-field_5a56fdb0872ed" name="acf[field_5a56fdb0872ed]" rows="8"></textarea>
</div>
<!-- H o n e y p o t -->
<div class="acf-input ohnohoney">
<div class="acf-input-wrap ohnohoney">
<textarea class="ohnohoney" id="c_message_ohnohoney" name="c_message_ohnohoney" rows="8"></textarea>
</div>
</div>
</div>
<?php
endif;
?>
<div class="acf-field acf-field-text acf-field--validate-email" style="display:none !important;" data-name="_validate_email" data-type="text" data-key="_validate_email">
<div class="acf-label"><label for="acf-_validate_email"><?php echo __('Validate Email', 'directorytheme'); ?></label></div>
<div class="acf-input">
<div class="acf-input-wrap"><input type="text" id="acf-_validate_email" name="acf[_validate_email]"></div>
</div>
<!-- H o n e y p o t -->
<div class="acf-input ohnohoney">
<div class="acf-input-wrap ohnohoney">
<input type="text" class="ohnohoney" id="validate_email_ohnohoney" name="validate_email_ohnohoney">
</div>
</div>
</div>
</div>
<?php
$enable_captcha_key1 = get_field('recaptch_field','option');
$contact_captcha_key = get_field('captcha_contact','option');
if($enable_captcha_key1 == '1' && $contact_captcha_key == '1'){
if( !empty($captcha_site_key) ){ ?>
<div class="col-md-12">
<div class="form-group">
<div class="g-recaptcha" data-sitekey="<?php echo $captcha_site_key; ?>" data-callback="verifyCaptcha"></div>
<div id="g-recaptcha-error"></div>
</div>
</div>
<?php
}
}
if(get_sendio_uid()){
$sandio_uid1 = get_sendio_uid();
?>
<input type="hidden" name="sendio_subscribe" value="sandiosubscribe">
<?php
}
?>
<div class="col-md-12">
<div class="form-group">
<input type="button" value="<?php if($form_button_text == '1' || empty($form_button_text)) { echo "Submit Message"; } else { echo $form_button_text; } ?>" class="btn btn-primary submit-form">
<input type="hidden" name="Action" value="contact_inq">
<?php
if( $maichimp_enable == 1){
if( $api_key != '' and $list_id != ''){ ?>
<input type="hidden" name="mailchimp_action" value="mailchimpsubscribe">
<?php
}
} ?>
</div>
</div>
</form>
</div>
</div><!--inner-->
</div><!--cp-container-->
<div class="contact_map">
<?php
$location = get_field('map', 'option');
if( !empty($location) ):
?>
<div class="acf-map">
<div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"></div>
</div>
<?php
endif;
?>
</div>
<script>
jQuery('#cp-container img').addClass('img-fluid');
jQuery('label[for="acf-_post_title"]').html("Name <span class='acf-required'>*</span>");
jQuery(".submit-form").click(function(){ jQuery('#contect_frm').submit(); });
</script>
<?php get_footer(); ?>