add hidden inputs in form
This commit is contained in:
@@ -301,6 +301,7 @@ document.write('<img src="'+pr+'?uid=18820&ref='+r+'&rd='+rd+'" width="88" heigh
|
|||||||
|
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
<?php get_template_part( 'partials/formhash' );?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -989,6 +989,37 @@ function adddr_hash(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//AMP
|
||||||
|
|
||||||
|
function add_amp_endpoint() {
|
||||||
|
add_rewrite_endpoint('amp', EP_PERMALINK);
|
||||||
|
}
|
||||||
|
add_action('init', 'add_amp_endpoint');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function custom_amp_template($template) {
|
||||||
|
|
||||||
|
if ( is_singular('post') && (isset($_GET['amp']) && $_GET['amp'] === '1')) {
|
||||||
|
$new_template = locate_template(array('single-amp.php'));
|
||||||
|
if (!empty($new_template)) {
|
||||||
|
return $new_template;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
add_filter('template_include', 'custom_amp_template');
|
||||||
|
|
||||||
|
function custom_amp_link() {
|
||||||
|
if (is_single()) {
|
||||||
|
$amp_url = get_permalink() . 'amp=1';
|
||||||
|
echo '<link rel="amphtml" href="' . esc_url($amp_url) . '">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_action('wp_head', 'custom_amp_link');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Пример замены изображений на AMP-изображения в контенте поста
|
// Пример замены изображений на AMP-изображения в контенте поста
|
||||||
function convert_images_to_amp($content) {
|
function convert_images_to_amp($content) {
|
||||||
if (function_exists('is_amp_endpoint') && is_amp_endpoint()) {
|
if (function_exists('is_amp_endpoint') && is_amp_endpoint()) {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ get_header();
|
|||||||
<div id="fulltext">
|
<div id="fulltext">
|
||||||
|
|
||||||
<? // режим подтверждение подписки
|
<? // режим подтверждение подписки
|
||||||
|
|
||||||
if (isset( $_GET['id'] )){
|
if (isset( $_GET['id'] )){
|
||||||
|
|
||||||
$sanitized_id = sanitize_text_field( $_GET['id'] );
|
$sanitized_id = sanitize_text_field( $_GET['id'] );
|
||||||
@@ -22,12 +21,15 @@ if (isset( $_GET['id'] )){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elseif( !isset($_POST['mytext']) || $_POST['mytext'] !== ''){ // поле должно быть пустым - заполнить может только бот
|
||||||
|
echo '<p>Не можем подтвердить ваши данные. Пожалуйста, повторите попытку.</p>';
|
||||||
|
}
|
||||||
|
|
||||||
elseif ( !isset($_POST['subscription_nonce']) || !wp_verify_nonce($_POST['subscription_nonce'], 'subscription_form_nonce') ) {
|
elseif ( !isset($_POST['subscription_nonce']) || !wp_verify_nonce($_POST['subscription_nonce'], 'subscription_form_nonce') ) {
|
||||||
echo ('<p>Неверный запрос. Пожалуйста, повторите попытку.</p>');
|
echo ('<p>Неверный запрос. Пожалуйста, повторите попытку.</p>');
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif( !isset($_POST['addrr']) || $_POST['addrr'] !== adddr_hash() ){
|
elseif( !isset($_POST['addrhash']) || $_POST['addrhash'] !== adddr_hash() ){
|
||||||
echo '<p>Не можем опеределить ваши данные. Пожалуйста, повторите попытку.</p>';
|
echo '<p>Не можем опеределить ваши данные. Пожалуйста, повторите попытку.</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
25
partials/formhash.php
Executable file
25
partials/formhash.php
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
<?$addrhash = adddr_hash();
|
||||||
|
if ($addrhash !== null):?>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|
||||||
|
let form = document.getElementById('form-right');
|
||||||
|
let inputAdded = false;
|
||||||
|
|
||||||
|
form.addEventListener('mouseenter', function() {
|
||||||
|
|
||||||
|
if (!inputAdded) {
|
||||||
|
|
||||||
|
var hiddenInput = document.createElement("input");
|
||||||
|
hiddenInput.type = "hidden";
|
||||||
|
hiddenInput.name = "addrhash"; // имя поля
|
||||||
|
hiddenInput.value = "<?=$addrhash?>"; // значение поля
|
||||||
|
|
||||||
|
form.appendChild(hiddenInput);
|
||||||
|
inputAdded = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}, { once: true });
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?endif;?>
|
||||||
@@ -2,14 +2,10 @@
|
|||||||
<div id="convert"></div>
|
<div id="convert"></div>
|
||||||
<div class="right_title"><?=vij_lang('email_title', LANG_VERSION);?></div>
|
<div class="right_title"><?=vij_lang('email_title', LANG_VERSION);?></div>
|
||||||
<div id="subscript-mail">
|
<div id="subscript-mail">
|
||||||
<form class="form-right" action="https://vetandlife.ru/subscript" method="post">
|
<form class="form-right" id="form-right" action="https://vetandlife.ru/subscript" method="post">
|
||||||
<input сlass="frm_mail" type="email" required name="email" placeholder="<?=vij_lang('your_mail', LANG_VERSION);?>">
|
<input сlass="frm_mail" type="email" required name="email" placeholder="<?=vij_lang('your_mail', LANG_VERSION);?>">
|
||||||
<?php wp_nonce_field('subscription_form_nonce', 'subscription_nonce'); ?>
|
<?php wp_nonce_field('subscription_form_nonce', 'subscription_nonce'); ?>
|
||||||
<?$addr = adddr_hash();
|
<input type="text" class="mytext" name="mytext" placeholder="Дополнительный текст">
|
||||||
if ($addr !== null):?>
|
|
||||||
<input type="hidden" name="addrr" value="<?=$addr?>">
|
|
||||||
<?endif?>
|
|
||||||
<input type="hidden" name="sender" value="info@vetandlife.ru">
|
|
||||||
<button class="frm_submit"><?=vij_lang('email_btn', LANG_VERSION);?></button>
|
<button class="frm_submit"><?=vij_lang('email_btn', LANG_VERSION);?></button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,12 +1,3 @@
|
|||||||
<?php
|
|
||||||
// Включение стилей AMP
|
|
||||||
function theme_amp_styles() {
|
|
||||||
wp_enqueue_style('theme-amp-style', get_template_directory_uri() . '/amp.css');
|
|
||||||
}
|
|
||||||
add_action('amp_post_template_css', 'theme_amp_styles');
|
|
||||||
|
|
||||||
// Начало AMP страницы
|
|
||||||
?>
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html amp>
|
<html amp>
|
||||||
<head>
|
<head>
|
||||||
@@ -16,10 +7,17 @@ add_action('amp_post_template_css', 'theme_amp_styles');
|
|||||||
<link rel="canonical" href="<?php echo esc_url(get_permalink()); ?>">
|
<link rel="canonical" href="<?php echo esc_url(get_permalink()); ?>">
|
||||||
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
|
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
|
||||||
<style amp-custom>
|
<style amp-custom>
|
||||||
<?php
|
body {
|
||||||
// Включение стилей из amp.css
|
font-family: Arial, sans-serif;
|
||||||
readfile(get_template_directory() . '/amp.css');
|
padding: 20px;
|
||||||
?>
|
}
|
||||||
|
h1 {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user