diff --git a/inc/classes/inContact/AdminMenu.php b/inc/classes/inContact/AdminMenu.php
index 5a33b59..0d0e053 100644
--- a/inc/classes/inContact/AdminMenu.php
+++ b/inc/classes/inContact/AdminMenu.php
@@ -2,8 +2,6 @@
namespace inContact;
-
-
/**
* Klasa Menus
*
@@ -14,7 +12,6 @@ namespace inContact;
*/
class AdminMenu
{
-
use Singleton;
function __construct()
@@ -24,99 +21,153 @@ class AdminMenu
protected function setupHooks()
{
- add_action('admin_menu', [$this, 'InContactAdminMenu']);
+ add_action("admin_menu", [$this, "InContactAdminMenu"]);
}
public function InContactAdminMenu($id)
{
- add_menu_page('ustawienia inContact', 'inContact', 'manage_options', 'wp-in-contact', array(
- $this,
- 'InContactSettings'
- ), 'dashicons-email', 100);
+ add_menu_page(
+ "ustawienia inContact",
+ "inContact",
+ "manage_options",
+ "wp-in-contact",
+ [$this, "InContactSettings"],
+ "dashicons-email",
+ 100,
+ );
}
public function InContactSettings()
{
- $updated = isset($_POST['updated']) ? $_POST['updated'] : '';
- $incontactconfig = isset($_REQUEST['incontact-config']) ? $_REQUEST['incontact-config'] : '';
- if ($updated === 'true' || wp_verify_nonce($incontactconfig, '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']);
+ $updated = isset($_POST["updated"]) ? $_POST["updated"] : "";
+ $incontactconfig = isset($_REQUEST["incontact-config"])
+ ? $_REQUEST["incontact-config"]
+ : "";
+ if (
+ $updated === "true" ||
+ wp_verify_nonce($incontactconfig, "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"],
+ );
?>
Ustawienia zostały zapisane!
addShortcode();
}
- protected function addShortcode()
+ protected function addShortcode(): void
{
- add_shortcode('in-contact', array(
- $this,
- 'inContact'
- ));
+ add_shortcode("in-contact", [$this, "inContact"]);
}
-
public function inContact($atts)
{
- $em_name = null;
- $em_mail = 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(!empty($_POST['em_name'])) { $em_name = $_POST['em_name']; } else {
- $error .= 'Please enter your name ';
- }
- if(!empty($_POST['em_mail'])) { $em_mail = $_POST['em_mail']; } else {
- $error .= 'Please enter your email address ';
- }
- if(!empty($_POST['em_message'])) { $em_message = $_POST['em_message']; } else {
- $error .= 'Please enter your message ';
- }
-
- $targetEmail = 'To: Tylkofotografia <' .get_option('incontact-target-mail') .'>';
+ $em_name = null;
+ $em_mail = null;
+ $em_message = null;
+ $class = null;
+ $html = null;
+ $error = null;
+ $body = null;
+ $telefon = null;
$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.'>'
- );
- $body = '
+ $form_submitted = $_SERVER["REQUEST_METHOD"] === "POST";
+
+ if (!empty($_POST["website"])) {
+ die();
+ }
+ if ($form_submitted) {
+ $emmsg = isset($_POST["emmsg"]) ? $_POST["emmsg"] : "";
+
+ if (!empty($_POST["em_name"])) {
+ $em_name = $_POST["em_name"];
+ } else {
+ $error .= "Please enter your name ";
+ }
+ if (!empty($_POST["em_mail"])) {
+ $em_mail = $_POST["em_mail"];
+ } else {
+ $error .= "Please enter your email address ";
+ }
+ if (!empty($_POST["em_message"])) {
+ $em_message = $_POST["em_message"];
+ } else {
+ $error .= "Please enter your message ";
+ }
+
+ $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 = [
+ "Content-Type: text/html; charset=UTF-8",
+ "From: " . $em_name . " <" . $em_mail . ">",
+ "Reply-To: " . $em_name . " <" . $em_mail . ">",
+ ];
+ $body = '
@@ -140,7 +148,7 @@ class Shortcode
Dane kontaktowe
Imię i nazwisko: {{IMIE_NAZWISKO}}
Email: {{EMAIL}}
-
+
📬 Treść wiadomości:
@@ -157,86 +165,117 @@ class Shortcode
';
- $body = str_replace(
- ['{{IMIE_NAZWISKO}}', '{{EMAIL}}', '{{TELEFON}}', '{{WIADOMOSC}}', '{{ROK}}'],
- [$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($error)) {
- $html .= '
' . $error . '
';
+ $body = str_replace(
+ [
+ "{{IMIE_NAZWISKO}}",
+ "{{EMAIL}}",
+ "{{TELEFON}}",
+ "{{WIADOMOSC}}",
+ "{{ROK}}",
+ ],
+ [
+ $em_name,
+ $em_mail,
+ $telefon,
+ str_replace(["\r\n", "\r", "\n"], "
", $em_message),
+ date("Y"),
+ ],
+ $body,
+ );
+ $gRecaptchaResponse = isset($_POST["g-recaptcha-response"])
+ ? $_POST["g-recaptcha-response"]
+ : "";
- } elseif ($emmsg == 'true')
- {
+ if (!empty($error)) {
+ $html .=
+ '
' .
+ $error .
+ "
";
+ } elseif ($emmsg == "true") {
+ $secret = get_option("incontact-secret-key");
+ $response = null;
+ if (get_option("incontact-site-key") != "") {
+ $reCaptcha = new \ReCaptcha\ReCaptcha($secret);
+ $resp = $reCaptcha
+ ->setExpectedHostname($_SERVER["SERVER_NAME"])
+ ->verify($gRecaptchaResponse, $_SERVER["REMOTE_ADDR"]);
+ if ($resp->isSuccess()) {
+ $canSend = true;
+ } else {
+ $errors = $resp->getErrorCodes();
+ }
+ } else {
+ $canSend = true;
+ }
- $secret = get_option('incontact-secret-key');
- $response = null;
- if (get_option('incontact-site-key') != '')
- {
- $reCaptcha = new \ReCaptcha\ReCaptcha($secret);
- $resp = $reCaptcha->setExpectedHostname($_SERVER['SERVER_NAME'])->verify($gRecaptchaResponse, $_SERVER['REMOTE_ADDR']);
- if ($resp->isSuccess())
- {
- $canSend = true;
+ if ($canSend) {
+ $mailResult = wp_mail(
+ $targetEmail,
+ $em_name,
+ $body,
+ $headers,
+ );
}
- else
- {
- $errors = $resp->getErrorCodes();
- }
- } else {
- $canSend = true;
}
-
- if ($canSend) {
- $mailResult = wp_mail($targetEmail, $em_name, $body, $headers);
- }
-
}
- }
- wp_enqueue_style('ContactCss', plugins_url( '/css/cform.css', __FILE__ ));
+ wp_enqueue_style("ContactCss", plugins_url("/css/cform.css", __FILE__));
- if (get_option('incontact-site-key') != '')
- {
- $html .= '
+ if (get_option("incontact-site-key") != "") {
+ $html .=
+ '
'."\n";
+ ' . "\n";
}
-
- $html .= '
+
+ $html .= '
';
- if ($mailResult == 1)
- {
- $html .= '
' . get_option('incontact-form-snd-ok') . '
';
+ if ($mailResult == 1) {
+ $html .=
+ '
' .
+ get_option("incontact-form-snd-ok") .
+ "
";
}
-
- $html .= '