181 lines
7.4 KiB
PHP
181 lines
7.4 KiB
PHP
<?php
|
|
|
|
namespace inContact;
|
|
|
|
/**
|
|
* Klasa Menus
|
|
*
|
|
* @link https://krzysztof-turek.com
|
|
*
|
|
* @package tylkofotografia.pl
|
|
* @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(
|
|
"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"],
|
|
);
|
|
?>
|
|
|
|
<div class="updated">
|
|
<p>Ustawienia zostały zapisane!</p>
|
|
</div> <?php
|
|
}
|
|
?>
|
|
<div class="wrap">
|
|
<h2><span class="dashicons dashicons-email"></span> InContact - Ustawienia</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>
|
|
<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>
|
|
<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>
|
|
<td><input name="incontact-target-mail" id="incontact-target-mail" type="text"
|
|
value="<?php echo get_option(
|
|
"incontact-target-mail",
|
|
); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th><label for="incontact-form-ph-name">Formularz - placeholder nazwa</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>
|
|
<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>
|
|
<td><input name="incontact-form-ph-message" id="incontact-form-ph-message" type="text"
|
|
value="<?php echo get_option(
|
|
"incontact-form-ph-message",
|
|
); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th><label for="incontact-form-name">Formularz - nazwa nazwa</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>
|
|
<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>
|
|
<td><input name="incontact-form-message" id="incontact-form-message" type="text"
|
|
value="<?php echo get_option(
|
|
"incontact-form-message",
|
|
); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<th><label for="incontact-form-snd-ok">Formularz - wiadomość wysłana popprawnie</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",
|
|
); ?>" class="regular-text"/></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p class="submit">
|
|
<input type="submit" name="submit" id="submit" class="button button-primary" value="Zapisz">
|
|
</p>
|
|
</form>
|
|
</div> <?php
|
|
}
|
|
}
|