- wp_unslash dla pól formularza i opcji (koniec z \' w mailach) - panel: wymagany nonce i manage_options, sanityzacja, esc_attr - reCAPTCHA: oczekiwana akcja i próg wyniku 0.5 - From z domeny strony, adres nadawcy tylko w Reply-To - honeypot bez die(), walidacja JS nie jest omijana - komunikat o nieudanej wysyłce, zachowanie wpisanych pól - nowy wygląd formularza (klasy ic-*) i szablon maila Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
187 lines
8.0 KiB
PHP
187 lines
8.0 KiB
PHP
<?php
|
|
|
|
namespace inContact;
|
|
|
|
/**
|
|
* Klasa Menus
|
|
*
|
|
* @link https://krzysztof-turek.com
|
|
*
|
|
* @package inContact
|
|
* @version 0.2
|
|
*/
|
|
class AdminMenu
|
|
{
|
|
use Singleton;
|
|
|
|
function __construct()
|
|
{
|
|
$this->setupHooks();
|
|
}
|
|
|
|
protected function setupHooks()
|
|
{
|
|
add_action("admin_menu", [$this, "InContactAdminMenu"]);
|
|
}
|
|
|
|
public function InContactAdminMenu($id)
|
|
{
|
|
add_menu_page(
|
|
__("InContact settings", "in-contact"),
|
|
__("InContact", "in-contact"),
|
|
"manage_options",
|
|
"wp-in-contact",
|
|
[$this, "InContactSettings"],
|
|
"dashicons-email",
|
|
100,
|
|
);
|
|
}
|
|
|
|
public function InContactSettings()
|
|
{
|
|
$nonce = isset($_POST["incontact-config"])
|
|
? sanitize_text_field(wp_unslash($_POST["incontact-config"]))
|
|
: "";
|
|
if (
|
|
$_SERVER["REQUEST_METHOD"] === "POST" &&
|
|
current_user_can("manage_options") &&
|
|
wp_verify_nonce($nonce, "incontact-update")
|
|
) {
|
|
$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">
|
|
<p><?php echo esc_html__(
|
|
"Settings saved!",
|
|
"in-contact",
|
|
); ?></p>
|
|
</div> <?php
|
|
}
|
|
?>
|
|
<div class="wrap">
|
|
<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"><?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 esc_attr(get_option("incontact-site-key")); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
<tr>
|
|
<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 esc_attr(get_option("incontact-secret-key")); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
<tr>
|
|
<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 esc_attr(get_option("incontact-target-mail")); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<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 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__(
|
|
"Form - placeholder email",
|
|
"in-contact",
|
|
); ?></label></th>
|
|
<td><input name="incontact-form-ph-email" id="incontact-form-ph-email" type="text"
|
|
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__(
|
|
"Form - placeholder message",
|
|
"in-contact",
|
|
); ?></label></th>
|
|
<td><input name="incontact-form-ph-message" id="incontact-form-ph-message" type="text"
|
|
value="<?php echo esc_attr(get_option("incontact-form-ph-message")); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<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 esc_attr(get_option("incontact-form-name")); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
<tr>
|
|
<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 esc_attr(get_option("incontact-form-email")); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
<tr>
|
|
<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 esc_attr(get_option("incontact-form-message")); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<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 esc_attr(get_option("incontact-form-snd-ok")); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p class="submit">
|
|
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php echo esc_attr__(
|
|
"Save",
|
|
"in-contact",
|
|
); ?>">
|
|
|
|
</p>
|
|
</form>
|
|
</div> <?php
|
|
}
|
|
}
|