Compare commits
2
Commits
86c13efadc
...
0f7eddd6a0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f7eddd6a0 | ||
|
|
f6b707a6f2 |
+210
-1
@@ -1 +1,210 @@
|
||||
form #website{ display:none; }
|
||||
/* ============================================================
|
||||
inContact — cform.css v0.3
|
||||
Dark, modern, photography-focused form styles
|
||||
Prefix: .ic- (inContact)
|
||||
============================================================ */
|
||||
|
||||
/* ---------- Tokeny ---------- */
|
||||
:root {
|
||||
--ic-bg: #ffffff;
|
||||
--ic-surface: #f8f8f8;
|
||||
--ic-border: #dde0e8;
|
||||
--ic-border-focus: #2563eb;
|
||||
--ic-text: #1a1d26;
|
||||
--ic-text-muted: #8a909e;
|
||||
--ic-accent: #2563eb;
|
||||
--ic-accent-dark: #1a4fc4;
|
||||
--ic-error: #dc2626;
|
||||
--ic-success-bg: #f0fdf4;
|
||||
--ic-success-txt: #166534;
|
||||
--ic-error-bg: #fef2f2;
|
||||
--ic-radius: 6px;
|
||||
--ic-transition: 200ms ease;
|
||||
--ic-font: inherit;
|
||||
}
|
||||
|
||||
/* ---------- Wrapper ---------- */
|
||||
.ic-wrap {
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
padding: 40px 48px;
|
||||
background: var(--ic-surface);
|
||||
border: 1px solid var(--ic-border);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.07);
|
||||
}
|
||||
|
||||
/* ---------- Alerty ---------- */
|
||||
.ic-alert {
|
||||
padding: 14px 18px;
|
||||
border-radius: var(--ic-radius);
|
||||
margin-bottom: 28px;
|
||||
font-size: 0.92rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.ic-alert--success {
|
||||
background: var(--ic-success-bg);
|
||||
color: var(--ic-success-txt);
|
||||
border: 1px solid #1e5e38;
|
||||
}
|
||||
|
||||
.ic-alert--error {
|
||||
background: var(--ic-error-bg);
|
||||
color: var(--ic-error);
|
||||
border: 1px solid #5e1e1e;
|
||||
}
|
||||
|
||||
/* ---------- Pola formularza ---------- */
|
||||
.ic-field {
|
||||
margin-bottom: 22px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Honeypot — ukryte */
|
||||
.ic-field--honey {
|
||||
position: absolute;
|
||||
left: -9999px;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.ic-field label {
|
||||
display: block;
|
||||
margin-bottom: 7px;
|
||||
font-size: 0.82rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ic-text-muted);
|
||||
}
|
||||
|
||||
.ic-field input[type="text"],
|
||||
.ic-field input[type="email"],
|
||||
.ic-field textarea {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
background: var(--ic-bg);
|
||||
border: 1px solid var(--ic-border);
|
||||
border-radius: var(--ic-radius);
|
||||
color: var(--ic-text);
|
||||
font-size: 1rem;
|
||||
font-family: inherit;
|
||||
line-height: 1.5;
|
||||
transition:
|
||||
border-color var(--ic-transition),
|
||||
box-shadow var(--ic-transition);
|
||||
box-sizing: border-box;
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.ic-field input::placeholder,
|
||||
.ic-field textarea::placeholder {
|
||||
color: var(--ic-text-muted);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.ic-field input:focus,
|
||||
.ic-field textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--ic-border-focus);
|
||||
box-shadow: 0 0 0 3px rgba(226, 176, 74, 0.15);
|
||||
}
|
||||
|
||||
.ic-field textarea {
|
||||
resize: vertical;
|
||||
min-height: 130px;
|
||||
}
|
||||
|
||||
/* ---------- Walidacja ---------- */
|
||||
.ic-field__error {
|
||||
display: none;
|
||||
margin-top: 6px;
|
||||
font-size: 0.8rem;
|
||||
color: var(--ic-error);
|
||||
}
|
||||
|
||||
.ic-field--invalid input,
|
||||
.ic-field--invalid textarea {
|
||||
border-color: var(--ic-error);
|
||||
box-shadow: 0 0 0 3px rgba(224, 85, 85, 0.15);
|
||||
}
|
||||
|
||||
.ic-field--invalid .ic-field__error {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ---------- reCAPTCHA ---------- */
|
||||
.ic-field--captcha {
|
||||
margin-bottom: 26px;
|
||||
}
|
||||
|
||||
/* reCAPTCHA ma własny iframe — filtrujemy tak żeby ciemne tło nie świeciło przez padding */
|
||||
.ic-field--captcha .g-recaptcha {
|
||||
display: inline-block;
|
||||
border-radius: var(--ic-radius);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ---------- Przycisk ---------- */
|
||||
.ic-field--submit {
|
||||
margin-top: 8px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#ic-submit {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 13px 32px;
|
||||
background: var(--ic-accent);
|
||||
color: #ffffff;
|
||||
border: none;
|
||||
border-radius: var(--ic-radius);
|
||||
font-size: 0.95rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background var(--ic-transition),
|
||||
transform var(--ic-transition),
|
||||
box-shadow var(--ic-transition);
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
#ic-submit svg {
|
||||
flex-shrink: 0;
|
||||
transition: transform var(--ic-transition);
|
||||
}
|
||||
|
||||
#ic-submit:hover {
|
||||
background: var(--ic-accent-dark);
|
||||
box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
#ic-submit:hover svg {
|
||||
transform: translateX(2px) translateY(-2px);
|
||||
}
|
||||
|
||||
#ic-submit:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#ic-submit:focus-visible {
|
||||
outline: 2px solid var(--ic-accent);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
/* ---------- Responsywność ---------- */
|
||||
@media (max-width: 640px) {
|
||||
.ic-wrap {
|
||||
padding: 28px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,49 +39,35 @@ class AdminMenu
|
||||
|
||||
public function InContactSettings()
|
||||
{
|
||||
$updated = isset($_POST["updated"]) ? $_POST["updated"] : "";
|
||||
$incontactconfig = isset($_REQUEST["incontact-config"])
|
||||
? $_REQUEST["incontact-config"]
|
||||
$nonce = isset($_POST["incontact-config"])
|
||||
? sanitize_text_field(wp_unslash($_POST["incontact-config"]))
|
||||
: "";
|
||||
if (
|
||||
$updated === "true" ||
|
||||
wp_verify_nonce($incontactconfig, "incontact-update")
|
||||
$_SERVER["REQUEST_METHOD"] === "POST" &&
|
||||
current_user_can("manage_options") &&
|
||||
wp_verify_nonce($nonce, "incontact-update")
|
||||
) {
|
||||
|
||||
update_option("incontact-site-key", $_POST["incontact-site-key"]);
|
||||
update_option(
|
||||
"incontact-secret-key",
|
||||
$_POST["incontact-secret-key"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-target-mail",
|
||||
$_POST["incontact-target-mail"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-form-ph-name",
|
||||
$_POST["incontact-form-ph-name"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-form-ph-email",
|
||||
$_POST["incontact-form-ph-email"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-form-ph-message",
|
||||
$_POST["incontact-form-ph-message"],
|
||||
);
|
||||
update_option("incontact-form-name", $_POST["incontact-form-name"]);
|
||||
update_option(
|
||||
"incontact-form-email",
|
||||
$_POST["incontact-form-email"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-form-message",
|
||||
$_POST["incontact-form-message"],
|
||||
);
|
||||
update_option(
|
||||
"incontact-form-snd-ok",
|
||||
$_POST["incontact-form-snd-ok"],
|
||||
);
|
||||
$fields = [
|
||||
"incontact-site-key" => "sanitize_text_field",
|
||||
"incontact-secret-key" => "sanitize_text_field",
|
||||
"incontact-target-mail" => "sanitize_email",
|
||||
"incontact-form-ph-name" => "sanitize_text_field",
|
||||
"incontact-form-ph-email" => "sanitize_text_field",
|
||||
"incontact-form-ph-message" => "sanitize_text_field",
|
||||
"incontact-form-name" => "sanitize_text_field",
|
||||
"incontact-form-email" => "sanitize_text_field",
|
||||
"incontact-form-message" => "sanitize_text_field",
|
||||
"incontact-form-snd-ok" => "sanitize_text_field",
|
||||
];
|
||||
foreach ($fields as $option => $sanitize) {
|
||||
if (!isset($_POST[$option])) {
|
||||
continue;
|
||||
}
|
||||
update_option(
|
||||
$option,
|
||||
$sanitize(wp_unslash($_POST[$option])),
|
||||
);
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="updated">
|
||||
@@ -108,9 +94,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-site-key" id="incontact-site-key" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-site-key",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-site-key")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-secret-key"><?php echo esc_html__(
|
||||
@@ -118,9 +102,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-secret-key" id="incontact-secret-key" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-secret-key",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-secret-key")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-target-mail"><?php echo esc_html__(
|
||||
@@ -128,9 +110,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-target-mail" id="incontact-target-mail" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-target-mail",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-target-mail")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -139,9 +119,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-ph-name" id="incontact-form-ph-name" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-ph-name",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-ph-name")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-form-ph-email"><?php echo esc_html__(
|
||||
@@ -149,9 +127,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-ph-email" id="incontact-form-ph-email" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-ph-email",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-ph-email")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-form-ph-message"><?php echo esc_html__(
|
||||
@@ -159,9 +135,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-ph-message" id="incontact-form-ph-message" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-ph-message",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-ph-message")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -170,9 +144,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-name" id="incontact-form-name" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-name",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-name")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-form-email"><?php echo esc_html__(
|
||||
@@ -180,9 +152,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-email" id="incontact-form-email" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-email",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-email")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><label for="incontact-form-message"><?php echo esc_html__(
|
||||
@@ -190,9 +160,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-message" id="incontact-form-message" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-message",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-message")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@@ -201,9 +169,7 @@ class AdminMenu
|
||||
"in-contact",
|
||||
); ?></label></th>
|
||||
<td><input name="incontact-form-snd-ok" id="incontact-form-snd-ok" type="text"
|
||||
value="<?php echo get_option(
|
||||
"incontact-form-snd-ok",
|
||||
); ?>" class="regular-text"/></td>
|
||||
value="<?php echo esc_attr(get_option("incontact-form-snd-ok")); ?>" class="regular-text"/></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -11,19 +11,25 @@ namespace inContact;
|
||||
* @version 0.2
|
||||
*/
|
||||
|
||||
class Enqueue {
|
||||
class Enqueue
|
||||
{
|
||||
use Singleton;
|
||||
|
||||
use Singleton;
|
||||
|
||||
function __construct() {
|
||||
/*function __construct() {
|
||||
add_action('wp_enqueue_scripts',[ $this, 'enqueueScripts']);
|
||||
}
|
||||
}*/
|
||||
|
||||
public function enqueueScripts() {
|
||||
global $pluginDirUrl, $pluginPath;
|
||||
wp_register_style('ContactCss', $pluginDirUrl.'css/inContact.css', [], filemtime( $pluginPath . 'css/inContact.css'), 'all');
|
||||
public function enqueueScripts()
|
||||
{
|
||||
global $pluginDirUrl, $pluginPath;
|
||||
wp_register_style(
|
||||
"ContactCss",
|
||||
$pluginDirUrl . "css/inContact.css",
|
||||
[],
|
||||
filemtime($pluginPath . "css/inContact.css"),
|
||||
"all",
|
||||
);
|
||||
|
||||
wp_enqueue_style('ContactCss');
|
||||
|
||||
}
|
||||
wp_enqueue_style("ContactCss");
|
||||
}
|
||||
}
|
||||
|
||||
+233
-184
@@ -3,12 +3,12 @@
|
||||
namespace inContact;
|
||||
|
||||
/**
|
||||
* Klasa Menus
|
||||
* Klasa Shortcode
|
||||
*
|
||||
* @link https://krzysztof-turek.com
|
||||
*
|
||||
* @package tylkofotografia.pl
|
||||
* @version 0.2
|
||||
* @version 0.3
|
||||
*/
|
||||
class Shortcode
|
||||
{
|
||||
@@ -21,7 +21,7 @@ class Shortcode
|
||||
|
||||
protected function addShortcode(): void
|
||||
{
|
||||
add_shortcode("in-contact", [$this, "inContact"]);
|
||||
add_shortcode("inContact", [$this, "inContact"]);
|
||||
}
|
||||
|
||||
public function inContact($atts)
|
||||
@@ -29,29 +29,34 @@ class Shortcode
|
||||
$em_name = null;
|
||||
$em_mail = null;
|
||||
$em_message = null;
|
||||
$class = null;
|
||||
$html = null;
|
||||
$error = null;
|
||||
$body = null;
|
||||
$telefon = null;
|
||||
$mailResult = 0;
|
||||
$canSend = false;
|
||||
$sendFailed = false;
|
||||
|
||||
$form_submitted = $_SERVER["REQUEST_METHOD"] === "POST";
|
||||
|
||||
if (!empty($_POST["website"])) {
|
||||
die();
|
||||
}
|
||||
global $pluginDirUrl;
|
||||
|
||||
// Honeypot — bot dostaje pozorny sukces, mail nie jest wysyłany
|
||||
$isBot = !empty($_POST["website"]);
|
||||
|
||||
if ($form_submitted) {
|
||||
$emmsg = isset($_POST["emmsg"]) ? $_POST["emmsg"] : "";
|
||||
|
||||
// Walidacja pól
|
||||
if (!empty($_POST["em_name"])) {
|
||||
$em_name = $_POST["em_name"];
|
||||
$em_name = sanitize_text_field(wp_unslash($_POST["em_name"]));
|
||||
} else {
|
||||
$error .=
|
||||
esc_html__("Please enter your name", "in-contact") .
|
||||
"<br />";
|
||||
}
|
||||
if (!empty($_POST["em_mail"])) {
|
||||
$em_mail = $_POST["em_mail"];
|
||||
if (!empty($_POST["em_mail"]) && is_email($_POST["em_mail"])) {
|
||||
$em_mail = sanitize_email(wp_unslash($_POST["em_mail"]));
|
||||
} else {
|
||||
$error .=
|
||||
esc_html__(
|
||||
@@ -60,41 +65,47 @@ class Shortcode
|
||||
) . "<br />";
|
||||
}
|
||||
if (!empty($_POST["em_message"])) {
|
||||
$em_message = $_POST["em_message"];
|
||||
$em_message = sanitize_textarea_field(
|
||||
wp_unslash($_POST["em_message"]),
|
||||
);
|
||||
} else {
|
||||
$error .=
|
||||
esc_html__("Please enter your message", "in-contact") .
|
||||
"<br />";
|
||||
}
|
||||
|
||||
$targetEmail =
|
||||
"To: Tylkofotografia <" .
|
||||
get_option("incontact-target-mail") .
|
||||
">";
|
||||
$mailResult = 0;
|
||||
$headers = "MIME-Version: 1.0" . "\r\n";
|
||||
$headers .=
|
||||
"Content-type: text/html; charset=" .
|
||||
get_bloginfo("charset") .
|
||||
"" .
|
||||
"\r\n";
|
||||
$headers .= "From: " . $em_name . " <" . $em_mail . ">" . "\r\n";
|
||||
// Budowanie emaila
|
||||
// From z domeny strony (SPF/DMARC), adres nadawcy tylko w Reply-To
|
||||
$siteHost = (string) wp_parse_url(home_url(), PHP_URL_HOST);
|
||||
if (strpos($siteHost, "www.") === 0) {
|
||||
$siteHost = substr($siteHost, 4);
|
||||
}
|
||||
$headerChars = ["\"", "<", ">", "\r", "\n"];
|
||||
$fromName = str_replace(
|
||||
$headerChars,
|
||||
"",
|
||||
wp_specialchars_decode(get_bloginfo("name"), ENT_QUOTES),
|
||||
);
|
||||
$replyName = str_replace($headerChars, "", (string) $em_name);
|
||||
$headers = [
|
||||
"Content-Type: text/html; charset=UTF-8",
|
||||
"From: " . $em_name . " <" . $em_mail . ">",
|
||||
"Reply-To: " . $em_name . " <" . $em_mail . ">",
|
||||
"From: " . $fromName . " <wordpress@" . $siteHost . ">",
|
||||
"Reply-To: " . $replyName . " <" . $em_mail . ">",
|
||||
];
|
||||
|
||||
$targetEmail = get_option("incontact-target-mail");
|
||||
$emailTitle = __("New message from contact form", "in-contact");
|
||||
$emailHeading = __("Contact details", "in-contact");
|
||||
$emailNameLabel = __("Name and surname", "in-contact");
|
||||
$emailEmailLabel = __("Email", "in-contact");
|
||||
$emailMessageHeading = __("Message content", "in-contact");
|
||||
$emailMsgHeading = __("Message content", "in-contact");
|
||||
$emailReplyLabel = __("Reply to message", "in-contact");
|
||||
$emailFooter = __(
|
||||
"This email was generated automatically by the website contact form.",
|
||||
"in-contact",
|
||||
);
|
||||
$emailRights = __("All rights reserved.", "in-contact");
|
||||
|
||||
$body =
|
||||
'<!DOCTYPE html>
|
||||
<html lang="pl">
|
||||
@@ -104,70 +115,24 @@ class Shortcode
|
||||
esc_html($emailTitle) .
|
||||
'</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f5f5f5;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.container {
|
||||
width: 90%;
|
||||
max-width: 600px;
|
||||
margin: 20px auto;
|
||||
background-color: #ffffff;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.header {
|
||||
background-color: #3a7bd5;
|
||||
color: #ffffff;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.content {
|
||||
padding: 20px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.content h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
.footer {
|
||||
background-color: #f1f1f1;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
color: #777777;
|
||||
}
|
||||
.button {
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
margin-top: 20px;
|
||||
background-color: #3a7bd5;
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.info {
|
||||
background-color: #f9f9f9;
|
||||
border-left: 4px solid #3a7bd5;
|
||||
padding: 10px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.container {
|
||||
width: 95%;
|
||||
}
|
||||
}
|
||||
body { font-family: Arial, sans-serif; background-color: #f5f5f5; margin: 0; padding: 0; }
|
||||
.container { width: 90%; max-width: 600px; margin: 20px auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 0 10px rgba(0,0,0,.1); }
|
||||
.header { background-color: #1a1a2e; color: #ffffff; padding: 20px; text-align: center; }
|
||||
.header h1 { margin: 0; font-size: 20px; }
|
||||
.content { padding: 24px; line-height: 1.6; }
|
||||
.content h2 { margin-top: 0; color: #1a1a2e; }
|
||||
.info { background-color: #f9f9f9; border-left: 4px solid #e2b04a; padding: 12px 16px; margin: 16px 0; border-radius: 0 4px 4px 0; }
|
||||
.info h3 { margin: 0 0 8px; color: #1a1a2e; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }
|
||||
.button { display: inline-block; padding: 10px 20px; margin-top: 20px; background-color: #e2b04a; color: #1a1a2e; text-decoration: none; border-radius: 4px; font-weight: bold; }
|
||||
.footer { background-color: #f1f1f1; text-align: center; padding: 12px; font-size: 12px; color: #777; }
|
||||
@media (max-width: 600px) { .container { width: 95%; } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h1>' .
|
||||
<div class="header"><h1>' .
|
||||
esc_html($emailTitle) .
|
||||
'</h1>
|
||||
</div>
|
||||
'</h1></div>
|
||||
<div class="content">
|
||||
<h2>' .
|
||||
esc_html($emailHeading) .
|
||||
@@ -178,15 +143,12 @@ class Shortcode
|
||||
<p><strong>' .
|
||||
esc_html($emailEmailLabel) .
|
||||
':</strong> {{EMAIL}}</p>
|
||||
|
||||
|
||||
<div class="info">
|
||||
<h3>' .
|
||||
esc_html($emailMessageHeading) .
|
||||
':</h3>
|
||||
esc_html($emailMsgHeading) .
|
||||
'</h3>
|
||||
<p>{{WIADOMOSC}}</p>
|
||||
</div>
|
||||
|
||||
<a href="mailto:{{EMAIL}}" class="button">' .
|
||||
esc_html($emailReplyLabel) .
|
||||
'</a>
|
||||
@@ -195,14 +157,16 @@ class Shortcode
|
||||
' .
|
||||
esc_html($emailFooter) .
|
||||
'<br>
|
||||
© {{ROK}} Twoja Firma. ' .
|
||||
© {{ROK}} ' .
|
||||
esc_html(get_bloginfo("name")) .
|
||||
". " .
|
||||
esc_html($emailRights) .
|
||||
'
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
';
|
||||
</html>';
|
||||
|
||||
$body = str_replace(
|
||||
[
|
||||
"{{IMIE_NAZWISKO}}",
|
||||
@@ -212,35 +176,44 @@ class Shortcode
|
||||
"{{ROK}}",
|
||||
],
|
||||
[
|
||||
$em_name,
|
||||
$em_mail,
|
||||
$telefon,
|
||||
str_replace(["\r\n", "\r", "\n"], "<br />", $em_message),
|
||||
esc_html($em_name),
|
||||
esc_html($em_mail),
|
||||
esc_html($telefon),
|
||||
str_replace(
|
||||
["\r\n", "\r", "\n"],
|
||||
"<br />",
|
||||
esc_html($em_message),
|
||||
),
|
||||
date("Y"),
|
||||
],
|
||||
$body,
|
||||
);
|
||||
$gRecaptchaResponse = isset($_POST["g-recaptcha-response"])
|
||||
? $_POST["g-recaptcha-response"]
|
||||
: "";
|
||||
|
||||
// Obsługa błędów walidacji
|
||||
if (!empty($error)) {
|
||||
$html .=
|
||||
'<div class="alert alert-success" role="alert">' .
|
||||
'<div class="ic-alert ic-alert--error">' .
|
||||
$error .
|
||||
"</div>";
|
||||
} elseif ($emmsg == "true") {
|
||||
$secret = get_option("incontact-secret-key");
|
||||
$response = null;
|
||||
if (get_option("incontact-site-key") != "") {
|
||||
} elseif ($isBot) {
|
||||
$mailResult = 1;
|
||||
} elseif ($emmsg === "true") {
|
||||
// reCAPTCHA
|
||||
$gRecaptchaResponse = isset($_POST["g-recaptcha-response"])
|
||||
? $_POST["g-recaptcha-response"]
|
||||
: "";
|
||||
$siteKey = get_option("incontact-site-key");
|
||||
|
||||
if ($siteKey != "") {
|
||||
$secret = get_option("incontact-secret-key");
|
||||
$reCaptcha = new \ReCaptcha\ReCaptcha($secret);
|
||||
$resp = $reCaptcha
|
||||
->setExpectedHostname($_SERVER["SERVER_NAME"])
|
||||
->setExpectedAction("submit")
|
||||
->setScoreThreshold(0.5)
|
||||
->verify($gRecaptchaResponse, $_SERVER["REMOTE_ADDR"]);
|
||||
if ($resp->isSuccess()) {
|
||||
$canSend = true;
|
||||
} else {
|
||||
$errors = $resp->getErrorCodes();
|
||||
}
|
||||
} else {
|
||||
$canSend = true;
|
||||
@@ -254,98 +227,174 @@ class Shortcode
|
||||
$headers,
|
||||
);
|
||||
}
|
||||
$sendFailed = !$mailResult;
|
||||
}
|
||||
}
|
||||
wp_enqueue_style("ContactCss", plugins_url("/css/cform.css", __FILE__));
|
||||
|
||||
if (get_option("incontact-site-key") != "") {
|
||||
$html .=
|
||||
'<script src="https://www.google.com/recaptcha/api.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){window.setTimeout(function(){$(".alert").fadeTo(500,0).slideUp(500,function(){$(this).remove()})},2e3)}),$(document).ready(function(){"use strict";window.addEventListener("load",function(){var t=document.getElementsByClassName("needs-validation");Array.prototype.filter.call(t,function(t){t.addEventListener("submit",function(e){!1===t.checkValidity()&&(e.preventDefault(),e.stopPropagation()),t.classList.add("was-validated")},!1)})},!1)})();
|
||||
</script>' . "\n";
|
||||
// Enqueue styles & reCAPTCHA
|
||||
wp_enqueue_style(
|
||||
"inContactCss",
|
||||
$pluginDirUrl . "css/inContact.css?v=12",
|
||||
[],
|
||||
"0.3",
|
||||
);
|
||||
|
||||
$siteKey = get_option("incontact-site-key");
|
||||
if ($siteKey != "") {
|
||||
wp_enqueue_script(
|
||||
"recaptcha",
|
||||
"https://www.google.com/recaptcha/api.js?render=" . $siteKey,
|
||||
[],
|
||||
null,
|
||||
true,
|
||||
);
|
||||
|
||||
wp_add_inline_script(
|
||||
"recaptcha",
|
||||
"
|
||||
document.getElementById('ic-form').addEventListener('submit', function(e) {
|
||||
if (e.defaultPrevented) return;
|
||||
var token = document.getElementById('g-recaptcha-response').value;
|
||||
if (!token) {
|
||||
e.preventDefault();
|
||||
grecaptcha.ready(function() {
|
||||
grecaptcha.execute('" .
|
||||
esc_js($siteKey) .
|
||||
"', {action: 'submit'})
|
||||
.then(function(token) {
|
||||
document.getElementById('g-recaptcha-response').value = token;
|
||||
document.getElementById('ic-form').submit();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
$html .= '<div class="row justify-content-md-center">
|
||||
<div class="col-12">';
|
||||
// Budowanie HTML formularza
|
||||
$html .= '<div class="ic-wrap">';
|
||||
|
||||
if ($mailResult == 1) {
|
||||
$html .=
|
||||
'<div class="alert alert-success" role="alert">' .
|
||||
get_option("incontact-form-snd-ok") .
|
||||
'<div class="ic-alert ic-alert--success">' .
|
||||
esc_html(get_option("incontact-form-snd-ok")) .
|
||||
"</div>";
|
||||
} elseif ($sendFailed) {
|
||||
$html .=
|
||||
'<div class="ic-alert ic-alert--error">' .
|
||||
esc_html__(
|
||||
"The message could not be sent. Please try again.",
|
||||
"in-contact",
|
||||
) .
|
||||
"</div>";
|
||||
}
|
||||
|
||||
// Po nieudanej próbie pola zachowują wpisane wartości
|
||||
$keep = $form_submitted && $mailResult != 1;
|
||||
$valName = $keep ? esc_attr((string) $em_name) : "";
|
||||
$valMail = $keep ? esc_attr((string) $em_mail) : "";
|
||||
$valMessage = $keep ? esc_textarea((string) $em_message) : "";
|
||||
|
||||
$html .= '<form action="" method="post" id="ic-form" novalidate>';
|
||||
$html .=
|
||||
'<div class="jumbotron"><form action="" class="needs-validation" novalidate method="post" id="demo-form">
|
||||
<input type="hidden" name="emmsg" value="true" />
|
||||
<input type="text" id="website" name="website" />
|
||||
<div class="jumbotron">
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-2 control-label">' .
|
||||
get_option("incontact-form-name") .
|
||||
'</label>
|
||||
<div class="col-12">
|
||||
<input type="text" class="form-control" id="name" name="em_name" placeholder="' .
|
||||
get_option("incontact-form-ph-name") .
|
||||
'" value="" required>
|
||||
<div class="invalid-feedback">
|
||||
' .
|
||||
'<input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response">';
|
||||
$html .= '<input type="hidden" name="emmsg" value="true" />';
|
||||
|
||||
// Honeypot — ukryte pole
|
||||
$html .=
|
||||
'<div class="ic-field ic-field--honey" aria-hidden="true">' .
|
||||
'<input type="text" id="website" name="website" tabindex="-1" autocomplete="off" />' .
|
||||
"</div>";
|
||||
|
||||
// Pole: Nazwa
|
||||
$html .=
|
||||
'<div class="ic-field">' .
|
||||
'<label for="ic-name">' .
|
||||
esc_html(get_option("incontact-form-name")) .
|
||||
"</label>" .
|
||||
'<input type="text" id="ic-name" name="em_name" value="' .
|
||||
$valName .
|
||||
'" placeholder="' .
|
||||
esc_attr(get_option("incontact-form-ph-name")) .
|
||||
'" required />' .
|
||||
'<span class="ic-field__error">' .
|
||||
esc_html__("Please enter your name!", "in-contact") .
|
||||
'
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email" class="col-2 control-label">' .
|
||||
get_option("incontact-form-email") .
|
||||
'</label>
|
||||
<div class="col-12">
|
||||
<input type="email" class="form-control" id="email" name="em_mail" placeholder="' .
|
||||
get_option("incontact-form-ph-email") .
|
||||
'" value="" required>
|
||||
<div class="invalid-feedback">
|
||||
' .
|
||||
"</span>" .
|
||||
"</div>";
|
||||
|
||||
// Pole: Email
|
||||
$html .=
|
||||
'<div class="ic-field">' .
|
||||
'<label for="ic-email">' .
|
||||
esc_html(get_option("incontact-form-email")) .
|
||||
"</label>" .
|
||||
'<input type="email" id="ic-email" name="em_mail" value="' .
|
||||
$valMail .
|
||||
'" placeholder="' .
|
||||
esc_attr(get_option("incontact-form-ph-email")) .
|
||||
'" required />' .
|
||||
'<span class="ic-field__error">' .
|
||||
esc_html__("Please enter your email address!", "in-contact") .
|
||||
'
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<p class="col-2 control-label">' .
|
||||
get_option("incontact-form-message") .
|
||||
'</p>
|
||||
<div class="col-12">
|
||||
<textarea class="form-control" rows="4" name="em_message" placeholder="' .
|
||||
get_option("incontact-form-ph-message") .
|
||||
'" required></textarea>
|
||||
<div class="invalid-feedback">
|
||||
' .
|
||||
"</span>" .
|
||||
"</div>";
|
||||
|
||||
// Pole: Wiadomość
|
||||
$html .=
|
||||
'<div class="ic-field">' .
|
||||
'<label for="ic-message">' .
|
||||
esc_html(get_option("incontact-form-message")) .
|
||||
"</label>" .
|
||||
'<textarea id="ic-message" name="em_message" rows="5" placeholder="' .
|
||||
esc_attr(get_option("incontact-form-ph-message")) .
|
||||
'" required>' .
|
||||
$valMessage .
|
||||
'</textarea>' .
|
||||
'<span class="ic-field__error">' .
|
||||
esc_html__("Please enter your message!", "in-contact") .
|
||||
'
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-4">
|
||||
<div class="g-recaptcha" data-sitekey="' .
|
||||
get_option("incontact-site-key") .
|
||||
'"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<p></p>
|
||||
<div class="col-4">
|
||||
<button id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
|
||||
<i class="fas fa-paper-plane"></i> ' .
|
||||
"</span>" .
|
||||
"</div>";
|
||||
|
||||
// Przycisk
|
||||
$html .=
|
||||
'<div class="ic-field ic-field--submit">' .
|
||||
'<button type="submit" id="ic-submit">' .
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>' .
|
||||
" " .
|
||||
esc_html__("Send", "in-contact") .
|
||||
'
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div></div>';
|
||||
"</button>" .
|
||||
"</div>";
|
||||
|
||||
$html .= "</form>";
|
||||
$html .= "</div>"; // .ic-wrap
|
||||
|
||||
// Inline JS — walidacja bez Bootstrap
|
||||
$html .= "<script>
|
||||
(function(){
|
||||
var form = document.getElementById('ic-form');
|
||||
if (!form) return;
|
||||
form.addEventListener('submit', function(e) {
|
||||
var valid = true;
|
||||
form.querySelectorAll('[required]').forEach(function(field) {
|
||||
var wrapper = field.closest('.ic-field');
|
||||
if (!field.value.trim()) {
|
||||
wrapper.classList.add('ic-field--invalid');
|
||||
valid = false;
|
||||
} else {
|
||||
wrapper.classList.remove('ic-field--invalid');
|
||||
}
|
||||
});
|
||||
if (!valid) e.preventDefault();
|
||||
});
|
||||
form.querySelectorAll('[required]').forEach(function(field) {
|
||||
field.addEventListener('input', function() {
|
||||
if (field.value.trim()) {
|
||||
field.closest('.ic-field').classList.remove('ic-field--invalid');
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>";
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -131,3 +131,7 @@ msgstr "Podaj swoją wiadomość!"
|
||||
#: inc/classes/inContact/Shortcode.php
|
||||
msgid "Send"
|
||||
msgstr "Wyślij"
|
||||
|
||||
#: inc/classes/inContact/Shortcode.php
|
||||
msgid "The message could not be sent. Please try again."
|
||||
msgstr "Nie udało się wysłać wiadomości. Spróbuj ponownie."
|
||||
|
||||
@@ -130,3 +130,7 @@ msgstr ""
|
||||
#: inc/classes/inContact/Shortcode.php
|
||||
msgid "Send"
|
||||
msgstr ""
|
||||
|
||||
#: inc/classes/inContact/Shortcode.php
|
||||
msgid "The message could not be sent. Please try again."
|
||||
msgstr ""
|
||||
|
||||
Reference in New Issue
Block a user