diff --git a/inc/classes/inContact/Shortcode.php b/inc/classes/inContact/Shortcode.php index 30128db..7808817 100644 --- a/inc/classes/inContact/Shortcode.php +++ b/inc/classes/inContact/Shortcode.php @@ -31,27 +31,31 @@ class Shortcode } - public function inContact($atts) + public function inContact($atts) { $em_name = null; $em_mail = null; - $em_meeessage = null; + $em_message = null; $class = null; $html = null; $error = null; $body = null; $telefon = null; - + $mailResult = 0; + $form_submitted = ($_SERVER['REQUEST_METHOD'] === 'POST'); + if(!empty($_POST['website'])) die(); + if ($form_submitted) { $emmsg = (isset($_POST['emmsg']) ? $_POST['emmsg'] : ''); - if(isset($_POST['em_name'])) { $em_name = $_POST['em_name']; } else { - $error .= 'Proszę wprowadź nazwę'; + + if(!empty($_POST['em_name'])) { $em_name = $_POST['em_name']; } else { + $error .= 'Please enter your name
'; } - if(isset($_POST['em_mail'])) { $em_mail = $_POST['em_mail']; } else { - $error .= 'Proszę wprowadź adres email'; + if(!empty($_POST['em_mail'])) { $em_mail = $_POST['em_mail']; } else { + $error .= 'Please enter your email address
'; } - if(isset($_POST['em_meeessage'])) { $em_meeessage = $_POST['em_meeessage']; } else { - $error .= 'Proszę wprowadź tersć wiadmości'; + if(!empty($_POST['em_message'])) { $em_message = $_POST['em_message']; } else { + $error .= 'Please enter your message
'; } $targetEmail = 'To: Tylkofotografia <' .get_option('incontact-target-mail') .'>'; @@ -64,9 +68,6 @@ class Shortcode 'From: ' . $em_name . ' <'.$em_mail.'>', 'Reply-To: ' . $em_name . ' <'.$em_mail.'>' ); - - $gRecaptchaResponse = (isset($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : ''); - $body = ' @@ -156,16 +157,19 @@ class Shortcode '; - $body = str_replace( + $body = str_replace( ['{{IMIE_NAZWISKO}}', '{{EMAIL}}', '{{TELEFON}}', '{{WIADOMOSC}}', '{{ROK}}'], - [$em_name, $em_mail, $telefon, nl2br($em_meeessage), date("Y")], - $body -); + [$em_name, $em_mail, $telefon, str_replace(array("\r\n", "\r", "\n"), "
", $em_message), date("Y")], + $body +) ; + //$gRecaptchaResponse = (isset($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : ''); + + - if (!empty($atts['class'])) { + /*if (!empty($atts['class'])) { $class = $atts['class']; - } - if ($emmsg == 'true' && $error) { + }*/ + if (!empty($error)) { $html .= ''; } elseif ($emmsg == 'true') @@ -184,47 +188,49 @@ class Shortcode $errors = $resp->getErrorCodes(); }*/ } - + } wp_enqueue_style('ContactCss', plugins_url( '/css/cform.css', __FILE__ )); - $html .= ' + /*$html .= ' '."\n"; - $html .= '
+ '."\n";*/ + + $html .= '
'; if ($mailResult == 1) { - $html .= ''; + $html .= ''; } + $html .= '
- +
- +
- Wprowadź nazwę! + Please enter your name!
- +
- Podaj adres email! + Please enter your email address!
-

Wiadomość

+

Message

- +
- Wprowadź treść wiadmości! + Please enter your message!
@@ -234,9 +240,10 @@ class Shortcode
+

@@ -244,6 +251,7 @@ class Shortcode
'; + return $html; }