addShortcode(); } protected function addShortcode() { add_shortcode('in-contact', array( $this, 'inContact' )); } public function inContact($atts) { $em_name = null; $em_mail = null; $em_meeessage = null; $class = null; $html = null; $error = null; $body = null; $telefon = null; if(!empty($_POST['website'])) die(); $emmsg = (isset($_POST['emmsg']) ? $_POST['emmsg'] : ''); if(isset($_POST['em_name'])) { $em_name = $_POST['em_name']; } else { $error .= 'Proszę wprowadź nazwę'; } if(isset($_POST['em_mail'])) { $em_mail = $_POST['em_mail']; } else { $error .= 'Proszę wprowadź adres email'; } if(isset($_POST['em_meeessage'])) { $em_meeessage = $_POST['em_meeessage']; } else { $error .= 'Proszę wprowadź tersć wiadmości'; } $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"; $headers = array( 'Content-Type: text/html; charset=UTF-8', 'From: ' . $em_name . ' <'.$em_mail.'>', 'Reply-To: ' . $em_name . ' <'.$em_mail.'>' ); $gRecaptchaResponse = (isset($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : ''); $body = ' Nowa wiadomość z formularza kontaktowego

📩 Nowa wiadomość z formularza

Dane kontaktowe

Imię i nazwisko: {{IMIE_NAZWISKO}}

Email: {{EMAIL}}

📬 Treść wiadomości:

{{WIADOMOSC}}

Odpowiedz na wiadomość
'; $body = str_replace( ['{{IMIE_NAZWISKO}}', '{{EMAIL}}', '{{TELEFON}}', '{{WIADOMOSC}}', '{{ROK}}'], [$em_name, $em_mail, $telefon, nl2br($em_meeessage), date("Y")], $body ); if (!empty($atts['class'])) { $class = $atts['class']; } if ($emmsg == 'true' && $error) { $html .= ''; } elseif ($emmsg == 'true') { $secret = get_option('incontact-secret-key'); $response = null; /*$reCaptcha = new \ReCaptcha\ReCaptcha($secret); $resp = $reCaptcha->setExpectedHostname($_SERVER['SERVER_NAME'])->verify($gRecaptchaResponse, $_SERVER['REMOTE_ADDR']); if ($resp->isSuccess()) {*/ $mailResult = wp_mail($targetEmail, $em_name, $body, $headers); /*} else { $errors = $resp->getErrorCodes(); }*/ } wp_enqueue_style('ContactCss', plugins_url( '/css/cform.css', __FILE__ )); $html .= ' '."\n"; $html .= '
'; if ($mailResult == 1) { $html .= ''; } $html .= '
Wprowadź nazwę!
Podaj adres email!

Wiadomość

Wprowadź treść wiadmości!
'; return $html; } }