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.6 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4
woowbot-woocommerce-chatbot / class-plugin-deactivate-feedback.php
woowbot-woocommerce-chatbot Last commit date
css 1 year ago fonts 1 year ago images 1 year ago js 1 year ago lang 1 year ago qc-support-promo-page 1 year ago class-plugin-deactivate-feedback.php 1 year ago class-qc-free-plugin-upgrade-notice.php 1 year ago functions.php 1 year ago qcld-recommendbot-plugin.php 1 year ago qcld-woowbot-info-page.php 1 year ago qcld-woowbot.php 1 year ago readme.txt 1 year ago woowbot-slick-button.png 1 year ago
class-plugin-deactivate-feedback.php
428 lines
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 if( ! class_exists( 'Wp_Usage_Feedback') ) {
9
10 class Wp_Usage_Feedback {
11
12 private $wpbot_version = '1.0.0';
13 private $home_url = '';
14 private $plugin_file = '';
15 private $plugin_name = '';
16 private $options = array();
17 private $require_optin = true;
18 private $include_goodbye_form = true;
19
20
21 /**
22 * Class constructor
23 *
24 * @param $_home_url The URL to the site we're sending data to
25 * @param $_plugin_file The file path for this plugin
26 * @param $_options Plugin options to track
27 * @param $_require_optin Whether user opt-in is required (always required on WordPress.org)
28 * @param $_include_goodbye_form Whether to include a form when the user deactivates
29 * @param $_marketing Marketing method:
30 * 0: Don't collect email addresses
31 * 1: Request permission same time as tracking opt-in
32 * 2: Request permission after opt-in
33 */
34 public function __construct(
35 $_plugin_file,
36 $_home_url,
37
38 $_require_optin=true,
39 $_include_goodbye_form=true) {
40
41 $this->plugin_file = $_plugin_file;
42 $this->home_url = 'plugins@quantumcloud.com';
43 $this->plugin_name = basename( $this->plugin_file, '.php' );
44
45 $this->require_optin = $_require_optin;
46 $this->include_goodbye_form = $_include_goodbye_form;
47
48
49 // Deactivation hook
50 register_deactivation_hook( $this->plugin_file, array( $this, 'deactivate_this_plugin' ) );
51
52 // Get it going
53 $this->init();
54
55 }
56
57 public function init() {
58
59 // Deactivation
60 add_filter( 'plugin_action_links_' . plugin_basename( $this->plugin_file ), array( $this, 'filter_action_links' ) );
61 add_action( 'admin_footer-plugins.php', array( $this, 'goodbye_ajax' ) );
62 add_action( 'wp_ajax_goodbye_form', array( $this, 'goodbye_form_callback' ) );
63
64
65 }
66
67 // In theme's functions.php or plug-in code:
68
69 function set_content_type(){
70 return "text/html";
71 }
72
73
74 /**
75 * Send the data to the home site
76 *
77 * @since 1.0.0
78 */
79 public function send_data( $body ) {
80 $message = '';
81 foreach($body as $key=>$value){
82
83 if($key=='active_plugins'){
84 $message .='<p> <b>'.$key.'</b>: '.(implode(', ',$value)).' </p>';
85 }
86 elseif($key=='inactive_plugins'){
87 $message .='<p> <b>'.$key.'</b>: '.(implode(', ',$value)).' </p>';
88 }else{
89 $message .='<p> <b>'.$key.'</b>: '.$value.' </p>';
90 }
91
92 }
93
94 $title = 'Plugin Deactivation Notice';
95 $headers = array('From: Anonymous <mailer@just-a-fake-from-address.com>');
96
97 add_filter( 'wp_mail_content_type', array($this, 'set_content_type') );
98 $email = wp_mail($this->home_url, $title, $message, $headers);
99 remove_filter('wp_mail_content_type', array($this, 'set_content_type'));
100
101 return $email;
102
103 }
104
105 /**
106 * Here we collect most of the data
107 *
108 * @since 1.0.0
109 */
110 public function get_data() {
111
112 // Use this to pass error messages back if necessary
113 $body['message'] = '';
114
115 // Use this array to send data back
116 $body = array();
117
118
119
120 /**
121 * Get our plugin data
122 * Currently we grab plugin name and version
123 * Or, return a message if the plugin data is not available
124 * @since 1.0.0
125 */
126 $plugin = $this->plugin_data();
127 if( empty( $plugin ) ) {
128 // We can't find the plugin data
129 // Send a message back to our home site
130 $body['message'] .= __( 'We can\'t detect any plugin information. This is most probably because you have not included the code in the plugin main file.', 'wpchatbot' );
131 $body['status'] = 'Data not found'; // Never translated
132 } else {
133 if( isset( $plugin['Name'] ) ) {
134 $body['plugin'] = sanitize_text_field( $plugin['Name'] );
135 }
136 if( isset( $plugin['Version'] ) ) {
137 $body['version'] = sanitize_text_field( $plugin['Version'] );
138 }
139
140 }
141
142 // Return the data
143 return $body;
144
145 }
146
147 /**
148 * Return plugin data
149 * @since 1.0.0
150 */
151 public function plugin_data() {
152 // Being cautious here
153 if( ! function_exists( 'get_plugin_data' ) ) {
154 include ABSPATH . '/wp-admin/includes/plugin.php';
155 }
156 // Retrieve current plugin information
157 $plugin = get_plugin_data( $this->plugin_file );
158 return $plugin;
159 }
160
161 /**
162 * Deactivating plugin
163 * @since 1.0.0
164 */
165 public function deactivate_this_plugin() {
166
167 $body = $this->get_data();
168 $body['status'] = 'Deactivated'; // Never translated
169 $body['deactivated_date'] = gmdate('Y-m-d');
170
171 // Add deactivation form data
172 if( false !== get_option( 'wpbot_deactivation_reason_' . $this->plugin_name ) ) {
173 $body['deactivation_reason'] = get_option( 'wpbot_deactivation_reason_' . $this->plugin_name );
174 delete_option('wpbot_deactivation_reason_' . $this->plugin_name);
175 delete_option('wp_chatbot_show_posts');
176 delete_option('wp_chatbot_show_pages');
177 delete_option('wp_chatbot_show_pages_list');
178 delete_option('wp_chatbot_exclude_post_list');
179 delete_option('wp_chatbot_show_wpcommerce');
180 }
181 if( false !== get_option( 'wpbot_deactivation_details_' . $this->plugin_name ) ) {
182 $body['deactivation_details'] = get_option( 'wpbot_deactivation_details_' . $this->plugin_name );
183 delete_option('wpbot_deactivation_details_' . $this->plugin_name);
184 delete_option('wp_chatbot_show_posts');
185 delete_option('wp_chatbot_show_pages');
186 delete_option('wp_chatbot_show_pages_list');
187 delete_option('wp_chatbot_exclude_post_list');
188 delete_option('wp_chatbot_show_wpcommerce');
189 }
190
191 if(isset($body['deactivation_reason']) or isset($body['deactivation_details']))
192 $this->send_data( $body );
193
194
195 }
196
197 /**
198 * Filter the deactivation link to allow us to present a form when the user deactivates the plugin
199 * @since 1.0.0
200 */
201 public function filter_action_links( $links ) {
202
203 if( isset( $links['deactivate'] ) && $this->include_goodbye_form ) {
204 $deactivation_link = $links['deactivate'];
205 // Insert an onClick action to allow form before deactivating
206 $deactivation_link = str_replace( '<a ', '<div class="wpb-goodbye-form-wrapper"><span class="wpb-goodbye-form" id="wpb-goodbye-form-' . esc_attr( $this->plugin_name ) . '"></span></div><a onclick="javascript:event.preventDefault();" id="wpb-goodbye-link-' . esc_attr( $this->plugin_name ) . '" ', $deactivation_link );
207 $links['deactivate'] = $deactivation_link;
208 }
209 return $links;
210 }
211
212 /*
213 * Form text strings
214 * These are non-filterable and used as fallback in case filtered strings aren't set correctly
215 * @since 1.0.0
216 */
217 public function form_default_text() {
218 $form = array();
219 $form['heading'] = __( 'Sorry to see you go', 'wpchatbot' );
220 $form['body'] = '';
221 $form['options'] = array(
222 __( 'Found a Bug', 'wpchatbot' ),
223 __( 'Need More Features', 'wpchatbot' ),
224 __( 'Deactivating Temporarily', 'wpchatbot' ),
225 __( 'Upgrading to Pro', 'wpchatbot' ),
226
227 );
228 $form['email'] = __( 'Please provide email so we can contact with bug fixes', 'wpchatbot' );
229 $form['details'] = __( 'Please provide some details so we can improve the plugin', 'wpchatbot' );
230 return $form;
231 }
232
233 /**
234 * Form text strings
235 * These can be filtered
236 * The filter hook must be unique to the plugin
237 * @since 1.0.0
238 */
239 public function form_filterable_text() {
240 $form = $this->form_default_text();
241 return apply_filters( 'wpbot_form_text_' . esc_attr( $this->plugin_name ), $form );
242 }
243
244 /**
245 * Form text strings
246 * These can be filtered
247 * @since 1.0.0
248 */
249 public function goodbye_ajax() {
250 // Get our strings for the form
251 $form = $this->form_filterable_text();
252 if( ! isset( $form['heading'] ) || ! isset( $form['body'] ) || ! isset( $form['options'] ) || ! is_array( $form['options'] ) || ! isset( $form['details'] ) ) {
253 // If the form hasn't been filtered correctly, we revert to the default form
254 $form = $this->form_default_text();
255 }
256 // Build the HTML to go in the form
257 $html = '<div class="wpb-goodbye-form-head"><strong>' . esc_html( $form['heading'] ) . '</strong></div>';
258 $html .= '<div class="wpb-goodbye-form-body"><p>' . esc_html( $form['body'] ) . '</p>';
259 if( is_array( $form['options'] ) ) {
260 $html .= '<div class="wpb-goodbye-options"><p>';
261 /*
262 foreach( $form['options'] as $option ) {
263 $html .= '<input type="radio" name="wpb-goodbye-options" id="' . str_replace( " ", "", esc_attr( $option ) ) . '" value="' . esc_attr( $option ) . '"> <label for="' . str_replace( " ", "", esc_attr( $option ) ) . '">' . esc_attr( $option ) . '</label><br>';
264 }
265 */
266 $html .= '</p><div id="wpb_additional_content" style=""><label for="wpb-goodbye-reasons">' . esc_html( $form['email'] ) .'</label><br><input type="email" name="wpb-goodbye-email" id="wpb-goodbye-email" value="'.get_option('admin_email').'" /> (Optional)';
267
268 $html .= '<br><label for="wpb-goodbye-reasons">' . esc_html( $form['details'] ) .'</label><textarea name="wpb-goodbye-reasons" id="wpb-goodbye-reasons" rows="2" style="width:100%"></textarea><div id="wpbot_deactivation_error"></div></div>';
269
270 $html .= '</div><!-- .wpb-goodbye-options -->';
271 }
272 $html .= '</div><!-- .wpb-goodbye-form-body -->';
273 $html .= '<p class="deactivating-spinner"><span class="spinner"></span> ' . __( 'Submitting form', 'wpbot-plugin' ) . '</p>';
274 ?>
275 <div class="wpb-goodbye-form-bg"></div>
276 <style type="text/css">
277 .wpb-form-active .wpb-goodbye-form-bg {
278 background: rgba( 0, 0, 0, .5 );
279 position: fixed;
280 top: 0;
281 left: 0;
282 width: 100%;
283 height: 100%;
284 }
285 .wpb-goodbye-form-wrapper {
286 position: relative;
287 z-index: 999;
288 display: none;
289 }
290 .wpb-form-active .wpb-goodbye-form-wrapper {
291 display: block;
292 }
293 .wpb-goodbye-form {
294 display: none;
295 }
296 .wpb-form-active .wpb-goodbye-form {
297 position: fixed;
298 max-width: 400px;
299 background: #fff;
300 white-space: normal;
301 z-index: 99;
302 top: 50%;
303 left: 50%;
304 transform: translate(-50%, -50%);
305 border-radius: 5px;
306 }
307 .wpb-goodbye-form-head {
308 background: #7a00aa;
309 color: #fff;
310 padding: 8px 18px;
311 text-align: center;
312 border-radius: 5px 5px 0px 0px;
313 }
314 .wpb-goodbye-form-body {
315 padding: 8px 18px;
316 color: #444;
317 }
318 .deactivating-spinner {
319 display: none;
320 }
321 .deactivating-spinner .spinner {
322 float: none;
323 margin: 4px 4px 0 18px;
324 vertical-align: bottom;
325 visibility: visible;
326 }
327 .wpb-goodbye-form-footer {
328 padding: 8px 18px;
329 min-height: 40px;
330 }
331 #wpbot_deactivation_error{color:red}
332 .wpbot_submit_deactivate{float:right}
333 .wpbot_just_deactivate{float: left;
334 font-size: 12px;
335 }
336 </style>
337 <script>
338 jQuery(document).ready(function($){
339 //$('input[type=radio]').live('change', function() {
340 $('input[type=radio]').on('change', function() {
341 if($(this).val()=='Deactivating Temporarily' || $(this).val()=='Upgrading to Pro'){
342 $('#wpb_additional_content').hide();
343 }else{
344 $('#wpb_additional_content').show();
345 }
346
347 });
348
349 $("#wpb-goodbye-link-<?php echo esc_attr( $this->plugin_name ); ?>").on("click",function(){
350 // We'll send the user to this deactivation link when they've completed or dismissed the form
351 var url = document.getElementById("wpb-goodbye-link-<?php echo esc_attr( $this->plugin_name ); ?>");
352 $('body').toggleClass('wpb-form-active');
353 $("#wpb-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?>").fadeIn();
354 $("#wpb-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?>").html( '<?php /* phpcs:ignore */ echo $html; ?>' + '<div class="wpb-goodbye-form-footer"><p><a class="wpbot_just_deactivate" href="'+url+'">Just Deactivate</a> <a id="wpb-submit-form" class="button primary wpbot_submit_deactivate" href="#">Submit and Deactivate</a></p></div>');
355 $('#wpb-goodbye-reasons').focus();
356 $('#wpb-submit-form').on('click', function(e){
357
358
359 e.preventDefault();
360
361 if($('#wpb-goodbye-reasons').val()==''){
362 jQuery('#wpbot_deactivation_error').html('Please provide some details to improve the plugin for you!');
363 $('#wpb-goodbye-reasons').focus();
364 return;
365 }
366
367 // As soon as we click, the body of the form should disappear
368 $("#wpb-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?> .wpb-goodbye-form-body").fadeOut();
369 $("#wpb-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?> .wpb-goodbye-form-footer").fadeOut();
370 // Fade in spinner
371 $("#wpb-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?> .deactivating-spinner").fadeIn();
372
373 var values = new Array();
374 $.each($("input[name='wpb-goodbye-options[]']:checked"), function(){
375 values.push($(this).val());
376 });
377 var email = $('#wpb-goodbye-email').val();
378 var details = $('#wpb-goodbye-reasons').val();
379 var data = {
380 'action': 'goodbye_form',
381 'values': values,
382 'details': details,
383 'email': email,
384 'security': "<?php echo sanitize_key( wp_create_nonce ( 'wpbot_goodbye_form' ) ); ?>",
385 'dataType': "json"
386 }
387
388 $.post(
389 ajaxurl,
390 data,
391 function(response){
392 // Redirect to original deactivation URL
393 window.location.href = url;
394 }
395 );
396 });
397 // If we click outside the form, the form will close
398 $('.wpb-goodbye-form-bg').on('click',function(){
399 $("#wpb-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?>").fadeOut();
400 $('body').removeClass('wpb-form-active');
401 });
402 });
403 });
404 </script>
405 <?php }
406
407 /**
408 * AJAX callback when the form is submitted
409 * @since 1.0.0
410 */
411 public function goodbye_form_callback() {
412 check_ajax_referer( 'wpbot_goodbye_form', 'security' );
413
414 if( isset( $_POST['details'] ) ) {
415 $details = sanitize_text_field( $_POST['details'] );
416 update_option( 'wpbot_deactivation_details_' . $this->plugin_name, $details );
417 }
418
419 echo 'success';
420 wp_die();
421 }
422
423 }
424
425 }
426
427
428