PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | libraries/html/feedback/thickbox.php +302 -0 1.6.1 → 1.8.16 View file →
@@ -1,0 +1,302 @@
1 +<?php
2 +/**
3 + * @package VikBooking - Libraries
4 + * @subpackage html.feedback
5 + * @author E4J s.r.l.
6 + * @copyright Copyright (C) 2018 E4J s.r.l. All Rights Reserved.
7 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 + * @link https://vikwp.com
9 + */
10 +
11 +// No direct access
12 +defined('ABSPATH') or die('No script kiddies please!');
13 +
14 +$deactivate_url_js = !empty($displayData['url']) ? $displayData['url'] : '#';
15 +$is_pro = isset($displayData['pro']) ? $displayData['pro'] : false;
16 +
17 +$plain_deactivation_url = JUri::getInstance();
18 +$plain_deactivation_url->setVar('feedback', 0);
19 +
20 +$doc_url = 'https://vikwp.com/support/documentation/vik-booking/';
21 +
22 +$options = array();
23 +
24 +$options[] = array(
25 + 'value' => '0',
26 + 'text' => __('No, thanks', 'vikbooking'),
27 + 'checked' => true,
28 +);
29 +
30 +$options[] = array(
31 + 'value' => 'The plugin is not working',
32 + 'text' => __('The plugin is not working', 'vikbooking'),
33 + 'notes' => true,
34 +);
35 +
36 +$options[] = array(
37 + 'value' => 'The plugin didn\'t work as expected',
38 + 'text' => __('The plugin didn\'t work as expected', 'vikbooking'),
39 + 'notes' => true,
40 +);
41 +
42 +if (!$is_pro)
43 +{
44 + $options[] = array(
45 + 'value' => 'The FREE version is too limited',
46 + 'text' => __('The FREE version is too limited', 'vikbooking'),
47 + 'notes' => array(
48 + 'required' => false,
49 + 'placeholder' => __('What features would you like to have?', 'vikbooking'),
50 + ),
51 + );
52 +}
53 +
54 +$options[] = array(
55 + 'value' => 'The plugin suddenly stopped working',
56 + 'text' => __('The plugin suddenly stopped working', 'vikbooking'),
57 + 'notes' => true,
58 +);
59 +
60 +$options[] = array(
61 + 'value' => 'The plugin broke my site',
62 + 'text' => __('The plugin broke my site', 'vikbooking'),
63 + 'notes' => array(
64 + 'placeholder' => __('Would you please explain what happened?', 'vikbooking'),
65 + ),
66 +);
67 +
68 +$options[] = array(
69 + 'value' => 'I couldn\'t understand how to get it working',
70 + 'text' => __('I couldn\'t understand how to get it working', 'vikbooking'),
71 + 'help' => sprintf(__('Did you read the plugin documentation? You can find it <a href="%s" target="_blank">here</a>.', 'vikbooking'), $doc_url),
72 +);
73 +
74 +$options[] = array(
75 + 'value' => 'I no longer need the plugin',
76 + 'text' => __('I no longer need the plugin', 'vikbooking'),
77 +);
78 +
79 +$options[] = array(
80 + 'value' => 'I\'m just debugging an issue',
81 + 'text' => __('I\'m just debugging an issue', 'vikbooking'),
82 +);
83 +
84 +$options[] = array(
85 + 'value' => 'I\'m unable to deactivate this plugin!',
86 + 'text' => __('I\'m unable to deactivate this plugin!', 'vikbooking'),
87 + 'help' => sprintf(__('In case you are experiencing some issues with the deactivation of this plugin, try to relaunch the page by appending <code>&feedback=0</code> to the URL. Otherwise just click <a href="%s">HERE</a>.', 'vikbooking'), (string) $plain_deactivation_url),
88 +);
89 +
90 +$options[] = array(
91 + 'value' => 'Other',
92 + 'text' => __('Other', 'vikbooking'),
93 + 'notes' => array(
94 + 'required' => true,
95 + 'placeholder' => __('Please give us more information', 'vikbooking'),
96 + ),
97 +);
98 +
99 +?>
100 +
101 +<style>
102 + .thickbox-loading {
103 + height: auto !important;
104 + }
105 +
106 + #TB_ajaxContent {
107 + width: calc(100% - 30px) !important;
108 + height: calc(100% - 45px) !important;
109 + }
110 +
111 + .th-box-body {
112 + height: calc(100% - 45px);
113 + }
114 +
115 + .th-box-footer {
116 + text-align: right;
117 + }
118 +
119 + .th-box-body div.form-field {
120 + margin: 5px 0;
121 + }
122 +
123 + .th-box-body blockquote {
124 + color: #7f8fa4;
125 + font-size: inherit;
126 + padding: 8px 24px;
127 + border-left: 4px solid #eaeaea;
128 + background: #fff;
129 + }
130 +
131 + .feedback-notes {
132 + margin-top: 7px;
133 + padding: 5px 10px;
134 + }
135 +
136 + textarea.invalid {
137 + border: 1px solid #900;
138 + }
139 +
140 + #vikbooking-deactivate-uemail {
141 + margin-bottom: 4px;
142 + display: inline-block;
143 + }
144 +</style>
145 +
146 +<div id="vikbooking-feedback" style="display: none;">
147 +
148 + <div class="th-box-body">
149 + <h2><?php echo __('Feedback', 'vikbooking'); ?></h2>
150 + <h3><?php echo __('If you have a moment, please let us know why you are deactivating.', 'vikbooking'); ?></h3>
151 +
152 + <form id="vikbooking-feedback-form">
153 +
154 + <?php
155 + foreach ($options as $i => $opt)
156 + {
157 + ?>
158 + <div class="form-field">
159 + <input
160 + type="radio"
161 + id="vbo-feed-opt-<?php echo $i; ?>"
162 + name="feedback_type"
163 + value="<?php echo esc_attr($opt['value']); ?>"
164 + <?php echo !empty($opt['checked']) ? 'checked="checked"' : ''; ?>
165 + />
166 + <label for="vbo-feed-opt-<?php echo $i; ?>"><?php echo $opt['text']; ?></label>
167 +
168 + <?php
169 + if (!empty($opt['help']))
170 + {
171 + ?>
172 + <blockquote
173 + class="feedback-help"
174 + style="<?php echo !empty($opt['checked']) ? '' : 'display:none;'; ?>"
175 + >
176 + <?php echo $opt['help']; ?>
177 + </blockquote>
178 + <?php
179 + }
180 +
181 + if (!empty($opt['notes']))
182 + {
183 + $opt['notes'] = (array) $opt['notes'];
184 +
185 + $placeholder = !empty($opt['notes']['placeholder'])
186 + ? $opt['notes']['placeholder']
187 + : __('Could you please write some extra notes?', 'vikbooking');
188 +
189 + ?>
190 + <textarea
191 + class="feedback-notes<?php echo !empty($opt['notes']['required']) ? ' required' : ''; ?>"
192 + placeholder="<?php echo $placeholder; ?>"
193 + style="<?php echo !empty($opt['checked']) ? '' : 'display:none;'; ?>"
194 + ></textarea>
195 + <?php
196 + }
197 + ?>
198 +
199 + </div>
200 + <?php
201 + }
202 + ?>
203 +
204 + <div class="form-field">
205 + <p style="margin-bottom: 2px;">
206 + <strong>
207 + <?php echo __('Would you like to be contacted by our team for a clarification?', 'vikbooking'); ?>
208 + </strong>
209 + </p>
210 + <span>
211 + <small>
212 + <?php echo __('If you believe you could have missed a feature in the plugin, please drop us your email and we will get back to you with <u>one</u> message.', 'vikbooking'); ?>
213 + </small>
214 + </span>
215 + <div>
216 + <input type="email" value="" placeholder="[email protected]" id="vikbooking-deactivate-uemail" />
217 + </div>
218 + </div>
219 +
220 + <p>
221 + <small>
222 + <span class="dashicons dashicons-editor-help"></span>&nbsp;
223 + <?php echo __('In addition to the specified information, the feedback will contain your IP address (for security reasons), your PHP version, your WordPress version and the plugin version. If provided, we will not use your email address for any kind of newsletter, nor will we share it with anyone. We will only answer to your questions.', 'vikbooking'); ?>
224 + </small>
225 + </p>
226 +
227 + </form>
228 + </div>
229 +
230 + <div class="th-box-footer">
231 + <a href="javascript: void(0);" id="vikbooking-deactivate" class="button button-primary">
232 + <?php echo __('Deactivate'); ?>
233 + </a>
234 + </div>
235 +
236 +</div>
237 +
238 +<script>
239 + jQuery(function() {
240 +
241 + jQuery('#vikbooking-feedback-form .form-field input[name="feedback_type"]').on('change', function() {
242 + var radio = jQuery('#vikbooking-feedback-form input[name="feedback_type"]:checked');
243 +
244 + jQuery('.feedback-help,.feedback-notes').hide();
245 + radio.siblings('.feedback-help,.feedback-notes').show().focus();
246 + });
247 +
248 + jQuery('#vikbooking-deactivate').on('click', function() {
249 + var radio = jQuery('#vikbooking-feedback-form input[name="feedback_type"]:checked');
250 +
251 + // get selected feedback type
252 + var type = radio.val();
253 +
254 + if (type == '0') {
255 + // deactivate automatically
256 + document.location.href = '<?php echo $deactivate_url_js; ?>';
257 + return;
258 + }
259 +
260 + // get textarea
261 + var textarea = radio.siblings('.feedback-notes');
262 + var comment = textarea.length ? textarea.val() : null;
263 +
264 + if (textarea.length && !textarea.val().length && textarea.hasClass('required')) {
265 + textarea.addClass('invalid');
266 + return;
267 + }
268 +
269 + // email address (optional)
270 + var uemail = jQuery('#vikbooking-deactivate-uemail').val();
271 +
272 + // disable button
273 + jQuery(this).attr('disabled', true);
274 +
275 + textarea.removeClass('invalid');
276 +
277 + // do ajax and redirect on success/failure
278 + jQuery.ajax({
279 + url: 'admin-ajax.php?action=vikbooking&task=feedback.submit',
280 + type: 'post',
281 + data: {
282 + type: type,
283 + notes: comment,
284 + email: uemail,
285 + },
286 + }).done(function(resp) {
287 + // keep a cookie for 7 days in order to stop showing the feedback
288 + // modal again and again
289 + var date = new Date();
290 + date.setDate(date.getDate() + 7);
291 + document.cookie = 'vikbooking_feedback=1; expires=' + date.toUTCString() + '; path=/; SameSite=Lax';
292 + // complete deactivation
293 + document.location.href = '<?php echo $deactivate_url_js; ?>';
294 + }).fail(function(err) {
295 + console.log(err);
296 + // complete deactivation
297 + document.location.href = '<?php echo $deactivate_url_js; ?>';
298 + });
299 + });
300 +
301 + });
302 +</script>