garantii.php
4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
function fenix_garantii ($atts)
{
$atts = shortcode_atts(
array(
'post' => '',
'id' => ''
),
$atts,
'fenix_garantii'
);
$out = '';
if ($atts['post']!=='')
{
$args = array(
'numberposts' => 1,
'post__in' => array($atts['post']),
'order' => 'ASC',
'limit' => 1
);
$posts = get_posts($args);
foreach($posts as $key=>$post)
{
$args_form = array(
'id_form' => 'form_consult',
'fields'=>array(
'author' => '<div class="mb-3">'.
'<label for="autor" class="form-label mb-3">Имя</label>'.
'<input type="text" class="form-control rounded-pill p-2 px-4" id="author" name="author" required="required" value="" size="30" />'.
'</div>',
'phone' => '<div class="mb-5">'.
'<label for="phone" class="form-label mb-3">Телефон</label>'.
'<input type="text" class="form-control rounded-pill p-2 px-4" id="phone" name="phone" required="required" value="" />'.
'</div>',
'email' => '<input type="hidden" name="email" id="email" value="email@'.$_SERVER['HTTP_HOST'].'" />',
'cookies' => '<input type="hidden" name="accept" id="accept" value="accept" />'
),
'comment_field' => '<input type="hidden" id="comment" name="comment" value="" />',
'label_submit' => 'Получить консультацию',
'submit_button' => '<button name="%1$s" type="submit" class="btn btn-lg btn-style-0 rounded-pill %3$s" role="submit" id="%2$s">%4$s</button>',
'comment_notes_before' => '',
'title_reply' => '<div class="form-preloader align-items-center justify-content-center d-flex d-none text-center position-absolute top-0 bottom-0 start-0 end-0 m-auto" style="z-index:1; background-color: rgba(255,255,255,0.8)">'.
'<div class="spinner-border" role="status">'.
'<span class="visually-hidden">Обработка...</span>'.
'</div>'.
'</div>',
'class_form' => 'needs-validation needs-validation',
'title_reply_before' => '',
'title_reply_after' => ''
);
$out = ''.
'<!--Мы на 100% гарантируем-->'.
'<div id="'.$atts['id'].'" class="fenix_garantii shadow-sm">'.
'<div class="container">'.
'<div class="row">'.
'<div class="col-12 pt-3 pt-md-5">'.
'<h1>'.$post->post_title.'</h1>'.
$post->post_content.
'<div class="position-relative">';
ob_start();
comment_form($args_form);
$out.=ob_get_clean();
$out.= ''.
'</div>'.
'</div>'.
'</div>'.
'</div>'.
'</div>';
unset($args_form);
}
wp_reset_postdata();
unset($key, $post, $posts, $args);
}
return $out;
}
add_shortcode('fenix_garantii', 'fenix_garantii');