hesabixWpTheme/page-tamas.php
2026-05-22 13:52:15 +03:30

175 lines
13 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* Template Name: تماس با ما
* قالب صفحه تماس
*
* @package Hesabix2
*/
if (!defined('ABSPATH')) {
exit;
}
$contact_sent = isset($_GET['contact_sent']) && $_GET['contact_sent'] === '1';
$contact_error = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['hesabix_contact_nonce'])) {
if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['hesabix_contact_nonce'])), 'hesabix_contact')) {
$contact_error = 'خطای امنیتی. لطفاً دوباره تلاش کنید.';
} else {
$name = isset($_POST['contact_name']) ? sanitize_text_field(wp_unslash($_POST['contact_name'])) : '';
$email = isset($_POST['contact_email']) ? sanitize_email(wp_unslash($_POST['contact_email'])) : '';
$phone = isset($_POST['contact_phone']) ? sanitize_text_field(wp_unslash($_POST['contact_phone'])) : '';
$subject = isset($_POST['contact_subject']) ? sanitize_text_field(wp_unslash($_POST['contact_subject'])) : '';
$message = isset($_POST['contact_message']) ? sanitize_textarea_field(wp_unslash($_POST['contact_message'])) : '';
if (empty($name) || empty($email) || empty($message)) {
$contact_error = 'نام، ایمیل و پیام الزامی هستند.';
} elseif (!is_email($email)) {
$contact_error = 'لطفاً یک ایمیل معتبر وارد کنید.';
} else {
$to = 'info@hesabix.ir';
$body = "نام و نام خانوادگی: $name\n";
$body .= "ایمیل: $email\n";
if ($phone) {
$body .= "شماره تماس: $phone\n";
}
$body .= "موضوع: $subject\n\n";
$body .= "پیام:\n$message";
$mail_subject = $subject ? '[تماس با ما] ' . $subject : '[تماس با ما] پیام جدید';
$headers = array(
'Content-Type: text/plain; charset=UTF-8',
'From: ' . get_bloginfo('name') . ' <' . get_option('admin_email') . '>',
'Reply-To: ' . $name . ' <' . $email . '>',
);
$sent = wp_mail($to, $mail_subject, $body, $headers);
if ($sent) {
wp_safe_redirect(add_query_arg('contact_sent', '1', get_permalink()));
exit;
}
$contact_error = 'ارسال پیام با خطا مواجه شد. لطفاً با ایمیل یا تلفن تماس بگیرید.';
}
}
}
get_header();
$wrap = 'max-w-6xl mx-auto px-4 sm:px-6 lg:px-8';
?>
<section class="py-12 sm:py-16 bg-white border-b border-slate-100">
<div class="<?php echo $wrap; ?>">
<div class="text-center mb-12">
<h1 class="text-3xl sm:text-4xl font-bold text-slate-800 mb-3">تماس با ما</h1>
<p class="text-slate-600 max-w-xl mx-auto">ما آماده پاسخگویی به سوالات و نیازهای شما هستیم</p>
</div>
<?php if ($contact_sent) : ?>
<div class="rounded-2xl bg-success-500/15 border border-success-400/40 text-success-700 px-6 py-4 mb-8 text-center">
<p class="font-medium">پیام شما با موفقیت ارسال شد. در اسرع وقت با شما تماس خواهیم گرفت.</p>
</div>
<?php endif; ?>
<?php if ($contact_error) : ?>
<div class="rounded-2xl bg-red-50 border border-red-200 text-red-700 px-6 py-4 mb-8 text-center">
<p class="font-medium"><?php echo esc_html($contact_error); ?></p>
</div>
<?php endif; ?>
<div class="grid lg:grid-cols-5 gap-10 lg:gap-14">
<!-- فرم -->
<div class="lg:col-span-3">
<div class="rounded-3xl border border-light-200 bg-white p-6 sm:p-8 shadow-sm">
<h2 class="text-xl font-bold text-slate-800 mb-6">ارسال پیام</h2>
<form method="post" action="" class="space-y-5">
<?php wp_nonce_field('hesabix_contact', 'hesabix_contact_nonce'); ?>
<div>
<label for="contact_name" class="block text-sm font-medium text-slate-700 mb-1.5">نام و نام خانوادگی <span class="text-red-500">*</span></label>
<input type="text" name="contact_name" id="contact_name" required value="<?php echo isset($_POST['contact_name']) ? esc_attr(sanitize_text_field(wp_unslash($_POST['contact_name']))) : ''; ?>" class="w-full px-4 py-3 rounded-xl border border-slate-200 focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition" placeholder="نام و نام خانوادگی">
</div>
<div>
<label for="contact_email" class="block text-sm font-medium text-slate-700 mb-1.5">ایمیل <span class="text-red-500">*</span></label>
<input type="email" name="contact_email" id="contact_email" required value="<?php echo isset($_POST['contact_email']) ? esc_attr(sanitize_email(wp_unslash($_POST['contact_email']))) : ''; ?>" class="w-full px-4 py-3 rounded-xl border border-slate-200 focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition" placeholder="example@email.com">
</div>
<div>
<label for="contact_phone" class="block text-sm font-medium text-slate-700 mb-1.5">شماره تماس <span class="text-slate-400 text-xs">(اختیاری)</span></label>
<input type="text" name="contact_phone" id="contact_phone" value="<?php echo isset($_POST['contact_phone']) ? esc_attr(sanitize_text_field(wp_unslash($_POST['contact_phone']))) : ''; ?>" class="w-full px-4 py-3 rounded-xl border border-slate-200 focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition" placeholder="۰۹۱۲۳۴۵۶۷۸۹">
</div>
<div>
<label for="contact_subject" class="block text-sm font-medium text-slate-700 mb-1.5">موضوع</label>
<input type="text" name="contact_subject" id="contact_subject" value="<?php echo isset($_POST['contact_subject']) ? esc_attr(sanitize_text_field(wp_unslash($_POST['contact_subject']))) : ''; ?>" class="w-full px-4 py-3 rounded-xl border border-slate-200 focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition" placeholder="موضوع پیام">
</div>
<div>
<label for="contact_message" class="block text-sm font-medium text-slate-700 mb-1.5">پیام شما <span class="text-red-500">*</span></label>
<textarea name="contact_message" id="contact_message" required rows="5" class="w-full px-4 py-3 rounded-xl border border-slate-200 focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition resize-none" placeholder="متن پیام خود را بنویسید..."><?php echo isset($_POST['contact_message']) ? esc_textarea(sanitize_textarea_field(wp_unslash($_POST['contact_message']))) : ''; ?></textarea>
</div>
<button type="submit" class="w-full inline-flex items-center justify-center gap-2 bg-accent-500 hover:bg-accent-400 text-white font-bold px-6 py-4 rounded-2xl transition shadow-md hover:shadow-lg">
ارسال پیام
</button>
</form>
</div>
</div>
<!-- اطلاعات تماس -->
<div class="lg:col-span-2 space-y-6">
<div class="rounded-3xl border border-light-200 bg-light-50/80 p-6 shadow-sm">
<h2 class="text-xl font-bold text-slate-800 mb-5">اطلاعات تماس</h2>
<ul class="space-y-5">
<li class="flex gap-4">
<span class="w-10 h-10 rounded-xl bg-brand-500/15 flex items-center justify-center text-brand-600 flex-shrink-0">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"/><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z"/></svg>
</span>
<div>
<span class="text-sm font-medium text-slate-500 block mb-0.5">آدرس</span>
<p class="text-slate-700 leading-relaxed">کرمانشاه، اسلام‌آباد غرب، شهرک صنعتی، خیابان کارگر، پلاک ۲</p>
</div>
</li>
<li class="flex gap-4">
<span class="w-10 h-10 rounded-xl bg-accent-500/15 flex items-center justify-center text-accent-600 flex-shrink-0">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/></svg>
</span>
<div>
<span class="text-sm font-medium text-slate-500 block mb-0.5">ایمیل</span>
<a href="mailto:info@hesabix.ir" class="text-brand-600 hover:text-brand-500 font-medium">info@hesabix.ir</a>
</div>
</li>
<li class="flex gap-4">
<span class="w-10 h-10 rounded-xl bg-success-500/15 flex items-center justify-center text-success-600 flex-shrink-0">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/></svg>
</span>
<div>
<span class="text-sm font-medium text-slate-500 block mb-0.5">تلفن</span>
<a href="tel:02191550290" class="text-slate-700 font-medium dir-ltr">۰۲۱-۹۱۵۵۰۲۹۰</a>
</div>
</li>
</ul>
</div>
<div class="rounded-3xl border border-light-200 bg-white p-6 shadow-sm">
<h3 class="text-lg font-bold text-slate-800 mb-4">ساعات کاری</h3>
<ul class="space-y-3 text-slate-600 text-sm">
<li class="flex justify-between"><span>شنبه تا چهارشنبه</span><span>۹:۰۰ – ۱۸:۰۰</span></li>
<li class="flex justify-between"><span>پنج‌شنبه</span><span>۹:۰۰ – ۱۴:۰۰</span></li>
<li class="flex justify-between"><span>جمعه</span><span class="text-slate-400">تعطیل</span></li>
</ul>
</div>
<div class="rounded-3xl border border-light-200 bg-white p-6 shadow-sm">
<h3 class="text-lg font-bold text-slate-800 mb-4">ما را در شبکه‌های اجتماعی دنبال کنید</h3>
<div class="flex flex-col gap-3">
<a href="https://t.me/hesabixacc" target="_blank" rel="noopener noreferrer" class="hesabix2-telegram-link inline-flex items-center gap-3 font-medium px-5 py-3 rounded-xl transition">
<svg class="w-6 h-6 flex-shrink-0" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/></svg>
تلگرام: hesabixacc
</a>
<a href="https://ble.ir/join/AZcuMtW5u8" target="_blank" rel="noopener noreferrer" class="hesabix2-bale-link inline-flex items-center gap-3 font-medium px-5 py-3 rounded-xl transition">
<svg class="w-6 h-6 flex-shrink-0" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>
بله — پیوستن به کانال
</a>
</div>
</div>
</div>
</div>
</div>
</section>
<?php get_footer(); ?>