Dodano obsługę tłumaczeń i ustawienia regionalne dla języka polskiego

This commit is contained in:
2026-01-15 23:13:51 +01:00
parent e13efb0fef
commit 17fb83bb32
6 changed files with 405 additions and 41 deletions

View File

@@ -1,26 +1,28 @@
<?php
/*
Plugin Name: In Contact test
Plugin URI: https://krzysztof-turek.com
Plugin Name: In Contact
Plugin URI: https://rawlab.pl
Description: Simple Contact Form
Version: 1.0.1
Author: Krzysztof Turek
Author URI: https://krzysztof-turek.com
License: GPL2
License URI: https://krzysztof-turek.com
License URI: https://rawlab.pl
Text Domain: in-contact
Domain Path: /languages
*/
define("INCONTACT_PLUGIN_FILE", __FILE__);
use inContact\Init;
$pluginDirUrl = plugin_dir_url( __FILE__ );
$pluginPath = plugin_dir_path( __FILE__ );
$pluginDirUrl = plugin_dir_url(__FILE__);
$pluginPath = plugin_dir_path(__FILE__);
if (file_exists(dirname(__FILE__) . "/inc/autoload.php")) {
require_once dirname(__FILE__) . "/inc/autoload.php";
}
if (class_exists("inContact\Init")) {
Init::getInstance();
}
}

View File

@@ -7,7 +7,7 @@ namespace inContact;
*
* @link https://krzysztof-turek.com
*
* @package tylkofotografia.pl
* @package inContact
* @version 0.2
*/
class AdminMenu
@@ -27,8 +27,8 @@ class AdminMenu
public function InContactAdminMenu($id)
{
add_menu_page(
"ustawienia inContact",
"inContact",
__("InContact settings", "in-contact"),
__("InContact", "in-contact"),
"manage_options",
"wp-in-contact",
[$this, "InContactSettings"],
@@ -85,33 +85,48 @@ class AdminMenu
?>
<div class="updated">
<p>Ustawienia zostały zapisane!</p>
<p><?php echo esc_html__(
"Settings saved!",
"in-contact",
); ?></p>
</div> <?php
}
?>
<div class="wrap">
<h2><span class="dashicons dashicons-email"></span> InContact - Ustawienia</h2>
<h2><span class="dashicons dashicons-email"></span> <?php echo esc_html__(
"InContact - Settings",
"in-contact",
); ?></h2>
<form method="POST">
<input type="hidden" name="updated" value="true"/>
<?php wp_nonce_field("incontact-update", "incontact-config"); ?>
<table class="form-table">
<tbody>
<tr>
<th><label for="incontact-site-key">Klucz witryny</label></th>
<th><label for="incontact-site-key"><?php echo esc_html__(
"Site key",
"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>
</tr>
<tr>
<th><label for="incontact-secret-key">Tajny klucz</label></th>
<th><label for="incontact-secret-key"><?php echo esc_html__(
"Secret key",
"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>
</tr>
<tr>
<th><label for="incontact-target-mail">Adresat (email)</label></th>
<th><label for="incontact-target-mail"><?php echo esc_html__(
"Recipient (email)",
"in-contact",
); ?></label></th>
<td><input name="incontact-target-mail" id="incontact-target-mail" type="text"
value="<?php echo get_option(
"incontact-target-mail",
@@ -119,21 +134,30 @@ class AdminMenu
</tr>
<tr>
<th><label for="incontact-form-ph-name">Formularz - placeholder nazwa</label></th>
<th><label for="incontact-form-ph-name"><?php echo esc_html__(
"Form - placeholder name",
"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>
</tr>
<tr>
<th><label for="incontact-form-ph-email">Formularz - placeholder email</label></th>
<th><label for="incontact-form-ph-email"><?php echo esc_html__(
"Form - placeholder email",
"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>
</tr>
<tr>
<th><label for="incontact-form-ph-message">Formularz - placeholder wiadomość</label></th>
<th><label for="incontact-form-ph-message"><?php echo esc_html__(
"Form - placeholder message",
"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",
@@ -141,21 +165,30 @@ class AdminMenu
</tr>
<tr>
<th><label for="incontact-form-name">Formularz - nazwa nazwa</label></th>
<th><label for="incontact-form-name"><?php echo esc_html__(
"Form - label name",
"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>
</tr>
<tr>
<th><label for="incontact-form-email">Formularz - nazwa email</label></th>
<th><label for="incontact-form-email"><?php echo esc_html__(
"Form - label email",
"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>
</tr>
<tr>
<th><label for="incontact-form-message">Formularz - nazwa wiadomość</label></th>
<th><label for="incontact-form-message"><?php echo esc_html__(
"Form - label message",
"in-contact",
); ?></label></th>
<td><input name="incontact-form-message" id="incontact-form-message" type="text"
value="<?php echo get_option(
"incontact-form-message",
@@ -163,7 +196,10 @@ class AdminMenu
</tr>
<tr>
<th><label for="incontact-form-snd-ok">Formularz - wiadomość wysłana popprawnie</label></th>
<th><label for="incontact-form-snd-ok"><?php echo esc_html__(
"Form - message sent successfully",
"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",
@@ -172,7 +208,11 @@ class AdminMenu
</tbody>
</table>
<p class="submit">
<input type="submit" name="submit" id="submit" class="button button-primary" value="Zapisz">
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_attr__(
"Save",
"in-contact",
); ?>">
</p>
</form>
</div> <?php

View File

@@ -16,8 +16,19 @@ class Init
function __construct()
{
$this->loadTextDomain();
Enqueue::getInstance();
AdminMenu::getInstance();
Shortcode::getInstance();
}
}
private function loadTextDomain(): void
{
add_action("plugins_loaded", function (): void {
load_plugin_textdomain(
"in-contact",
false,
dirname(plugin_basename(INCONTACT_PLUGIN_FILE)) . "/languages",
);
});
}
}

View File

@@ -46,17 +46,25 @@ class Shortcode
if (!empty($_POST["em_name"])) {
$em_name = $_POST["em_name"];
} else {
$error .= "Please enter your name </br>";
$error .=
esc_html__("Please enter your name", "in-contact") .
"<br />";
}
if (!empty($_POST["em_mail"])) {
$em_mail = $_POST["em_mail"];
} else {
$error .= "Please enter your email address </br>";
$error .=
esc_html__(
"Please enter your email address",
"in-contact",
) . "<br />";
}
if (!empty($_POST["em_message"])) {
$em_message = $_POST["em_message"];
} else {
$error .= "Please enter your message </br>";
$error .=
esc_html__("Please enter your message", "in-contact") .
"<br />";
}
$targetEmail =
@@ -76,11 +84,25 @@ class Shortcode
"From: " . $em_name . " <" . $em_mail . ">",
"Reply-To: " . $em_name . " <" . $em_mail . ">",
];
$body = '<!DOCTYPE html>
$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");
$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">
<head>
<meta charset="UTF-8">
<title>Nowa wiadomość z formularza kontaktowego</title>
<title>' .
esc_html($emailTitle) .
'</title>
<style>
body {
font-family: Arial, sans-serif;
@@ -142,24 +164,40 @@ class Shortcode
<body>
<div class="container">
<div class="header">
<h1>📩 Nowa wiadomość z formularza</h1>
<h1>📩 ' .
esc_html($emailTitle) .
'</h1>
</div>
<div class="content">
<h2>Dane kontaktowe</h2>
<p><strong>Imię i nazwisko:</strong> {{IMIE_NAZWISKO}}</p>
<p><strong>Email:</strong> {{EMAIL}}</p>
<h2>' .
esc_html($emailHeading) .
'</h2>
<p><strong>' .
esc_html($emailNameLabel) .
':</strong> {{IMIE_NAZWISKO}}</p>
<p><strong>' .
esc_html($emailEmailLabel) .
':</strong> {{EMAIL}}</p>
<div class="info">
<h3>📬 Treść wiadomości:</h3>
<h3>📬 ' .
esc_html($emailMessageHeading) .
':</h3>
<p>{{WIADOMOSC}}</p>
</div>
<a href="mailto:{{EMAIL}}" class="button">Odpowiedz na wiadomość</a>
<a href="mailto:{{EMAIL}}" class="button">' .
esc_html($emailReplyLabel) .
'</a>
</div>
<div class="footer">
Ten e-mail został wygenerowany automatycznie przez formularz kontaktowy strony.<br>
© {{ROK}} Twoja Firma. Wszelkie prawa zastrzeżone.
' .
esc_html($emailFooter) .
'<br>
© {{ROK}} Twoja Firma. ' .
esc_html($emailRights) .
'
</div>
</div>
</body>
@@ -251,7 +289,9 @@ class Shortcode
get_option("incontact-form-ph-name") .
'" value="" required>
<div class="invalid-feedback">
Please enter your name!
' .
esc_html__("Please enter your name!", "in-contact") .
'
</div>
</div>
</div>
@@ -264,7 +304,9 @@ class Shortcode
get_option("incontact-form-ph-email") .
'" value="" required>
<div class="invalid-feedback">
Please enter your email address!
' .
esc_html__("Please enter your email address!", "in-contact") .
'
</div>
</div>
</div>
@@ -277,7 +319,9 @@ class Shortcode
get_option("incontact-form-ph-message") .
'" required></textarea>
<div class="invalid-feedback">
Please enter your message!
' .
esc_html__("Please enter your message!", "in-contact") .
'
</div>
</div>
</div>
@@ -292,7 +336,9 @@ class Shortcode
<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> Send
<i class="fas fa-paper-plane"></i> ' .
esc_html__("Send", "in-contact") .
'
</button>
</div>
</div>

View File

@@ -0,0 +1,133 @@
msgid ""
msgstr ""
"Project-Id-Version: InContact 1.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-01 00:00+0000\n"
"PO-Revision-Date: 2024-01-01 00:00+0000\n"
"Last-Translator: \n"
"Language-Team: Polish\n"
"Language: pl_PL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: manual\n"
#: inc/classes/inContact/AdminMenu.php
msgid "InContact settings"
msgstr "Ustawienia InContact"
#: inc/classes/inContact/AdminMenu.php
msgid "InContact"
msgstr "InContact"
#: inc/classes/inContact/AdminMenu.php
msgid "Settings saved!"
msgstr "Ustawienia zostały zapisane!"
#: inc/classes/inContact/AdminMenu.php
msgid "InContact - Settings"
msgstr "InContact - Ustawienia"
#: inc/classes/inContact/AdminMenu.php
msgid "Site key"
msgstr "Klucz witryny"
#: inc/classes/inContact/AdminMenu.php
msgid "Secret key"
msgstr "Tajny klucz"
#: inc/classes/inContact/AdminMenu.php
msgid "Recipient (email)"
msgstr "Adresat (email)"
#: inc/classes/inContact/AdminMenu.php
msgid "Form - placeholder name"
msgstr "Formularz - placeholder nazwa"
#: inc/classes/inContact/AdminMenu.php
msgid "Form - placeholder email"
msgstr "Formularz - placeholder email"
#: inc/classes/inContact/AdminMenu.php
msgid "Form - placeholder message"
msgstr "Formularz - placeholder wiadomość"
#: inc/classes/inContact/AdminMenu.php
msgid "Form - label name"
msgstr "Formularz - nazwa nazwa"
#: inc/classes/inContact/AdminMenu.php
msgid "Form - label email"
msgstr "Formularz - nazwa email"
#: inc/classes/inContact/AdminMenu.php
msgid "Form - label message"
msgstr "Formularz - nazwa wiadomość"
#: inc/classes/inContact/AdminMenu.php
msgid "Form - message sent successfully"
msgstr "Formularz - wiadomość wysłana poprawnie"
#: inc/classes/inContact/AdminMenu.php
msgid "Save"
msgstr "Zapisz"
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your name"
msgstr "Wpisz swoje imię"
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your email address"
msgstr "Wpisz swój adres email"
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your message"
msgstr "Wpisz swoją wiadomość"
#: inc/classes/inContact/Shortcode.php
msgid "New message from contact form"
msgstr "Nowa wiadomość z formularza kontaktowego"
#: inc/classes/inContact/Shortcode.php
msgid "Contact details"
msgstr "Dane kontaktowe"
#: inc/classes/inContact/Shortcode.php
msgid "Name and surname"
msgstr "Imię i nazwisko"
#: inc/classes/inContact/Shortcode.php
msgid "Email"
msgstr "Email"
#: inc/classes/inContact/Shortcode.php
msgid "Message content"
msgstr "Treść wiadomości"
#: inc/classes/inContact/Shortcode.php
msgid "Reply to message"
msgstr "Odpowiedz na wiadomość"
#: inc/classes/inContact/Shortcode.php
msgid "This email was generated automatically by the website contact form."
msgstr "Ten e-mail został wygenerowany automatycznie przez formularz kontaktowy strony."
#: inc/classes/inContact/Shortcode.php
msgid "All rights reserved."
msgstr "Wszelkie prawa zastrzeżone."
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your name!"
msgstr "Podaj swoje imię!"
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your email address!"
msgstr "Podaj swój adres email!"
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your message!"
msgstr "Podaj swoją wiadomość!"
#: inc/classes/inContact/Shortcode.php
msgid "Send"
msgstr "Wyślij"

132
languages/in-contact.pot Normal file
View File

@@ -0,0 +1,132 @@
msgid ""
msgstr ""
"Project-Id-Version: InContact 1.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-01 00:00+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: manual\n"
#: inc/classes/inContact/AdminMenu.php
msgid "InContact settings"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "InContact"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Settings saved!"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "InContact - Settings"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Site key"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Secret key"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Recipient (email)"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Form - placeholder name"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Form - placeholder email"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Form - placeholder message"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Form - label name"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Form - label email"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Form - label message"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Form - message sent successfully"
msgstr ""
#: inc/classes/inContact/AdminMenu.php
msgid "Save"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your name"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your email address"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your message"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "New message from contact form"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Contact details"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Name and surname"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Email"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Message content"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Reply to message"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "This email was generated automatically by the website contact form."
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "All rights reserved."
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your name!"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your email address!"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Please enter your message!"
msgstr ""
#: inc/classes/inContact/Shortcode.php
msgid "Send"
msgstr ""