PluginProbe
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation / trunk
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation vtrunk
1.4.48 1.4.47 1.4.46 1.4.45 1.4.44 1.4.43 1.4.42 1.4.41 1.4.40 1.4.39 1.4.38 1.4.37 1.4.36 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 64 releases
optin / includes / utils / class-deactive.php

class-deactive.php in WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation trunk, at includes/utils/class-deactive.php

377 lines 11.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php //phpcs:ignore
2
3 namespace OPTN\Includes\Utils;
4
5 defined( 'ABSPATH' ) || exit;
6
7 /**
8 * Handles plugin deactivation feedback and reporting.
9 */
10 class Deactive {
11
12 /**
13 * Plugin slug
14 *
15 * @var string
16 */
17 private $plugin_slug = 'optin';
18
19 /**
20 * Constructor.
21 */
22 public function __construct() {
23 global $pagenow;
24
25 if ( 'plugins.php' === $pagenow ) {
26 add_action( 'admin_footer', array( $this, 'get_source_data_callback' ) );
27 }
28 add_action( 'wp_ajax_optn_deactive_plugin', array( $this, 'send_plugin_data' ) );
29 }
30
31 /**
32 * Send plugin deactivation data to remote server.
33 *
34 * @return void
35 */
36 public function send_plugin_data() {
37 DurbinClient::send( DurbinClient::DEACTIVATE_ACTION );
38 die();
39 }
40
41 /**
42 * Output deactivation modal markup, CSS, and JS.
43 *
44 * @return void
45 */
46 public function get_source_data_callback() {
47 $this->deactive_container_css();
48 $this->deactive_container_js();
49 $this->deactive_html_container();
50 }
51
52 /**
53 * Get deactivation reasons and field settings.
54 *
55 * @return array[] List of deactivation options.
56 */
57 public function get_deactive_settings() {
58 return array(
59 array(
60 'id' => 'not-working',
61 'input' => false,
62 'text' => __( 'The plugin isn’t working properly.', 'optin' ),
63 ),
64 array(
65 'id' => 'limited-features',
66 'input' => false,
67 'text' => __( 'Limited features on the free version.', 'optin' ),
68 ),
69 array(
70 'id' => 'better-plugin',
71 'input' => true,
72 'text' => __( 'I found a better plugin.', 'optin' ),
73 'placeholder' => __( 'Please share which plugin.', 'optin' ),
74 ),
75 array(
76 'id' => 'temporary-deactivation',
77 'input' => false,
78 'text' => __( "It's a temporary deactivation.", 'optin' ),
79 ),
80 array(
81 'id' => 'other',
82 'input' => true,
83 'text' => __( 'Other.', 'optin' ),
84 'placeholder' => __( 'Please share the reason.', 'optin' ),
85 ),
86 );
87 }
88
89 /**
90 * Output HTML for the deactivation modal.
91 *
92 * @return void
93 */
94 public function deactive_html_container() {
95 ?>
96 <div class="optn-deactive-modal" id="optn-deactive-deactive-modal">
97 <div class="optn-deactive-modal-wrap">
98
99 <div class="optn-deactive-modal-header">
100 <h2><?php esc_html_e( 'Quick Feedback', 'optin' ); ?></h2>
101 <button class="optn-deactive-modal-cancel"><span class="dashicons dashicons-no-alt"></span></button>
102 </div>
103
104 <div class="optn-deactive-modal-body">
105 <h3><?php esc_html_e( 'If you have a moment, please let us know why you are deactivating WowOptin:', 'optin' ); ?></h3>
106 <ul class="optn-deactive-modal-input">
107 <?php foreach ( $this->get_deactive_settings() as $key => $setting ) { ?>
108 <li>
109 <label>
110 <input type="radio" <?php echo 0 == $key ? 'checked="checked"' : ''; ?> id="<?php echo esc_attr( $setting['id'] ); ?>" name="<?php echo esc_attr( $this->plugin_slug ); ?>" value="<?php echo esc_attr( $setting['text'] ); ?>">
111 <div class="optn-deactive-reason-text"><?php echo esc_html( $setting['text'] ); ?></div>
112 <?php if ( isset( $setting['input'] ) && $setting['input'] ) { ?>
113 <textarea placeholder="<?php echo esc_attr( $setting['placeholder'] ); ?>" class="optn-deactive-reason-input <?php echo $key == 0 ? 'optn-deactive-active' : ''; ?> <?php echo esc_html( $setting['id'] ); ?>"></textarea>
114 <?php } ?>
115 </label>
116 </li>
117 <?php } ?>
118 </ul>
119 </div>
120
121 <div class="optn-deactive-modal-footer">
122 <a class="optn-deactive-modal-submit optn-deactive-btn optn-deactive-btn-primary" href="#"><?php esc_html_e( 'Submit & Deactivate', 'optin' ); ?><span class="dashicons dashicons-update rotate"></span></a>
123 <a class="optn-deactive-modal-deactive" href="#"><?php esc_html_e( 'Skip & Deactivate', 'optin' ); ?></a>
124 </div>
125
126 </div>
127 </div>
128 <?php
129 }
130
131 /**
132 * Output inline CSS for the modal.
133 *
134 * @return void
135 */
136 public function deactive_container_css() {
137 ?>
138 <style type="text/css">
139 .optn-deactive-modal {
140 position: fixed;
141 z-index: 99999;
142 top: 0;
143 right: 0;
144 bottom: 0;
145 left: 0;
146 background: rgba(0,0,0,0.5);
147 display: none;
148 box-sizing: border-box;
149 overflow: scroll;
150 }
151 .optn-deactive-modal * {
152 box-sizing: border-box;
153 }
154 .optn-deactive-modal.modal-active {
155 display: block;
156 }
157 .optn-deactive-modal-wrap {
158 max-width: 870px;
159 width: 100%;
160 position: relative;
161 margin: 10% auto;
162 background: #fff;
163 }
164 .optn-deactive-reason-input{
165 display: none;
166 }
167 .optn-deactive-reason-input.optn-deactive-active{
168 display: block;
169 }
170 .rotate{
171 animation: rotate 1.5s linear infinite;
172 }
173 @keyframes rotate{
174 to{ transform: rotate(360deg); }
175 }
176 .optn-deactive-popup-rotate{
177 animation: popupRotate 1s linear infinite;
178 }
179 @keyframes popupRotate{
180 to{ transform: rotate(360deg); }
181 }
182 #optn-deactive-deactive-modal {
183 background: rgb(0 0 0 / 85%);
184 overflow: hidden;
185 }
186 #optn-deactive-deactive-modal .optn-deactive-modal-wrap {
187 max-width: 570px;
188 border-radius: 5px;
189 margin: 5% auto;
190 overflow: hidden
191 }
192 #optn-deactive-deactive-modal .optn-deactive-modal-header {
193 padding: 17px 30px;
194 border-bottom: 1px solid #ececec;
195 display: flex;
196 align-items: center;
197 background: #f5f5f5;
198 }
199 #optn-deactive-deactive-modal .optn-deactive-modal-header .optn-deactive-modal-cancel {
200 padding: 0;
201 border-radius: 100px;
202 border: 1px solid #b9b9b9;
203 background: none;
204 color: #b9b9b9;
205 cursor: pointer;
206 transition: 400ms;
207 }
208 #optn-deactive-deactive-modal .optn-deactive-modal-header .optn-deactive-modal-cancel:focus {
209 color: red;
210 border: 1px solid red;
211 outline: 0;
212 }
213 #optn-deactive-deactive-modal .optn-deactive-modal-header .optn-deactive-modal-cancel:hover {
214 color: red;
215 border: 1px solid red;
216 }
217 #optn-deactive-deactive-modal .optn-deactive-modal-header h2 {
218 margin: 0;
219 padding: 0;
220 flex: 1;
221 line-height: 1;
222 font-size: 20px;
223 text-transform: uppercase;
224 color: #8e8d8d;
225 }
226 #optn-deactive-deactive-modal .optn-deactive-modal-body {
227 padding: 25px 30px;
228 }
229 #optn-deactive-deactive-modal .optn-deactive-modal-body h3{
230 padding: 0;
231 margin: 0;
232 line-height: 1.4;
233 font-size: 15px;
234 }
235 #optn-deactive-deactive-modal .optn-deactive-modal-body ul {
236 margin: 25px 0 10px;
237 }
238 #optn-deactive-deactive-modal .optn-deactive-modal-body ul li {
239 display: flex;
240 margin-bottom: 10px;
241 color: #807d7d;
242 }
243 #optn-deactive-deactive-modal .optn-deactive-modal-body ul li:last-child {
244 margin-bottom: 0;
245 }
246 #optn-deactive-deactive-modal .optn-deactive-modal-body ul li label {
247 align-items: center;
248 width: 100%;
249 }
250 #optn-deactive-deactive-modal .optn-deactive-modal-body ul li label input {
251 padding: 0 !important;
252 margin: 0;
253 display: inline-block;
254 }
255 #optn-deactive-deactive-modal .optn-deactive-modal-body ul li label textarea {
256 margin-top: 8px;
257 width: 350px;
258 }
259 #optn-deactive-deactive-modal .optn-deactive-modal-body ul li label .optn-deactive-reason-text {
260 margin-left: 8px;
261 display: inline-block;
262 }
263 #optn-deactive-deactive-modal .optn-deactive-modal-footer {
264 padding: 0 30px 30px 30px;
265 display: flex;
266 align-items: center;
267 }
268 #optn-deactive-deactive-modal .optn-deactive-modal-footer .optn-deactive-modal-submit {
269 display: flex;
270 align-items: center;
271 padding: 12px 22px;
272 border-radius: 3px;
273 background: #f97415;
274 color: #fff;
275 font-size: 16px;
276 font-weight: 600;
277 text-decoration: none;
278 }
279 #optn-deactive-deactive-modal .optn-deactive-modal-footer .optn-deactive-modal-submit span {
280 margin-left: 4px;
281 display: none;
282 }
283 #optn-deactive-deactive-modal .optn-deactive-modal-footer .optn-deactive-modal-submit.loading span {
284 display: block;
285 }
286 #optn-deactive-deactive-modal .optn-deactive-modal-footer .optn-deactive-modal-deactive {
287 margin-left: auto;
288 color: #c5c5c5;
289 text-decoration: none;
290 }
291 .wpxpo-btn-tracking-notice {
292 display: flex;
293 align-items: center;
294 flex-wrap: wrap;
295 padding: 5px 0;
296 }
297 .wpxpo-btn-tracking-notice .wpxpo-btn-tracking {
298 margin: 0 5px;
299 text-decoration: none;
300 }
301 </style>
302 <?php
303 }
304
305 /**
306 * Output inline JavaScript for the modal logic.
307 *
308 * @return void
309 */
310 public function deactive_container_js() {
311 ?>
312 <script type="text/javascript">
313 jQuery( document ).ready( function( $ ) {
314 'use strict';
315
316 // Modal Radio Input Click Action
317 $('.optn-deactive-modal-input input[type=radio]').on( 'change', function(e) {
318 $('.optn-deactive-reason-input').removeClass('optn-deactive-active');
319 $('.optn-deactive-modal-input').find( '.'+$(this).attr('id') ).addClass('optn-deactive-active');
320 });
321
322 // Modal Cancel Click Action
323 $( document ).on( 'click', '.optn-deactive-modal-cancel', function(e) {
324 $( '#optn-deactive-deactive-modal' ).removeClass( 'modal-active' );
325 });
326
327 $(document).on('click', function(event) {
328 const $popup = $('#optn-deactive-deactive-modal');
329 const $modalWrap = $popup.find('.optn-deactive-modal-wrap');
330
331 if ( !$modalWrap.is(event.target) && $modalWrap.has(event.target).length === 0 && $popup.hasClass('modal-active')) {
332 $popup.removeClass('modal-active');
333 }
334 });
335
336 // Deactivate Button Click Action
337 $( document ).on( 'click', '#deactivate-optin', function(e) {
338 e.preventDefault();
339 e.stopPropagation();
340 $( '#optn-deactive-deactive-modal' ).addClass( 'modal-active' );
341 $( '.optn-deactive-modal-deactive' ).attr( 'href', $(this).attr('href') );
342 $( '.optn-deactive-modal-submit' ).attr( 'href', $(this).attr('href') );
343 });
344
345 // Submit to Remote Server
346 $( document ).on( 'click', '.optn-deactive-modal-submit', function(e) {
347 e.preventDefault();
348
349 $(this).addClass('loading');
350 const url = $(this).attr('href')
351
352 $.ajax({
353 url: '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>',
354 type: 'POST',
355 data: {
356 action: 'optn_deactive_plugin',
357 cause_id: $('#optn-deactive-deactive-modal input[type=radio]:checked').attr('id'),
358 cause_title: $('#optn-deactive-deactive-modal .optn-deactive-modal-input input[type=radio]:checked').val(),
359 cause_details: $('#optn-deactive-deactive-modal .optn-deactive-reason-input.optn-deactive-active').val()
360 },
361 success: function (data) {
362 $( '#optn-deactive-deactive-modal' ).removeClass( 'modal-active' );
363 window.location.href = url;
364 },
365 error: function(xhr) {
366 console.log( 'Error occured. Please try again' + xhr.statusText + xhr.responseText );
367 },
368 });
369
370 });
371
372 });
373 </script>
374 <?php
375 }
376 }
377