1 <?php |
1 <?php |
2 /** |
2 /** |
3 * Displays the content of the dialog box when the user clicks on the "Deactivate" link on the plugin settings page |
3 * Displays the content of the dialog box when the user clicks on the "Deactivate" link on the plugin settings page |
|
4 * |
4 * @package BestWebSoft |
5 * @package BestWebSoft |
5 * @since 2.1.3 |
6 * @since 2.1.3 |
6 */ |
7 */ |
7 if ( ! defined( 'ABSPATH' ) ) |
8 if ( ! defined( 'ABSPATH' ) ) { |
8 exit; |
9 exit; |
|
10 } |
9 |
11 |
10 /** |
12 /** |
11 * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins |
13 * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins |
12 * page. |
14 * page. |
13 * |
15 * |
14 * @since 2.1.3 |
16 * @since 2.1.3 |
15 */ |
17 */ |
16 if ( ! function_exists( 'bws_add_deactivation_feedback_dialog_box' ) ) { |
18 if ( ! function_exists( 'bws_add_deactivation_feedback_dialog_box' ) ) { |
17 function bws_add_deactivation_feedback_dialog_box() { |
19 function bws_add_deactivation_feedback_dialog_box() { |
18 global $bstwbsftwppdtplgns_active_plugins; |
20 global $bstwbsftwppdtplgns_active_plugins; |
19 if ( empty( $bstwbsftwppdtplgns_active_plugins ) ) |
21 if ( empty( $bstwbsftwppdtplgns_active_plugins ) ) { |
20 return; |
22 return; |
|
23 } |
21 |
24 |
22 $contact_support_template = __( 'Need help? We are ready to answer your questions.', 'bestwebsoft' ) . ' <a href="https://support.bestwebsoft.com/hc/en-us/requests/new" target="_blank">' . __( 'Contact Support', 'bestwebsoft' ) . '</a>'; |
25 $contact_support_template = __( 'Need help? We are ready to answer your questions.', 'bestwebsoft' ) . ' <a href="https://support.bestwebsoft.com/hc/en-us/requests/new" target="_blank">' . __( 'Contact Support', 'bestwebsoft' ) . '</a>'; |
23 |
26 |
24 $reasons = array( |
27 $reasons = array( |
25 array( |
28 array( |
26 'id' => 'NOT_WORKING', |
29 'id' => 'NOT_WORKING', |
27 'text' => __( 'The plugin is not working', 'bestwebsoft' ), |
30 'text' => __( 'The plugin is not working', 'bestwebsoft' ), |
28 'input_type' => 'textarea', |
31 'input_type' => 'textarea', |
29 'input_placeholder' => esc_attr__( "Kindly share what didn't work so we can fix it in future updates...", 'bestwebsoft' ) |
32 'input_placeholder' => __( "Kindly share what didn't work so we can fix it in future updates...", 'bestwebsoft' ), |
30 ), |
33 ), |
31 array( |
34 array( |
32 'id' => 'DIDNT_WORK_AS_EXPECTED', |
35 'id' => 'DIDNT_WORK_AS_EXPECTED', |
33 'text' => __( "The plugin didn't work as expected", 'bestwebsoft' ), |
36 'text' => __( "The plugin didn't work as expected", 'bestwebsoft' ), |
34 'input_type' => 'textarea', |
37 'input_type' => 'textarea', |
35 'input_placeholder' => esc_attr__( 'What did you expect?', 'bestwebsoft' ) |
38 'input_placeholder' => __( 'What did you expect?', 'bestwebsoft' ), |
36 ), |
39 ), |
37 array( |
40 array( |
38 'id' => 'SUDDENLY_STOPPED_WORKING', |
41 'id' => 'SUDDENLY_STOPPED_WORKING', |
39 'text' => __( 'The plugin suddenly stopped working', 'bestwebsoft' ), |
42 'text' => __( 'The plugin suddenly stopped working', 'bestwebsoft' ), |
40 'input_type' => '', |
43 'input_type' => '', |
41 'input_placeholder' => '', |
44 'input_placeholder' => '', |
42 'internal_message' => $contact_support_template |
45 'internal_message' => $contact_support_template, |
43 ), |
46 ), |
44 array( |
47 array( |
45 'id' => 'BROKE_MY_SITE', |
48 'id' => 'BROKE_MY_SITE', |
46 'text' => __( 'The plugin broke my site', 'bestwebsoft' ), |
49 'text' => __( 'The plugin broke my site', 'bestwebsoft' ), |
47 'input_type' => '', |
50 'input_type' => '', |
48 'input_placeholder' => '', |
51 'input_placeholder' => '', |
49 'internal_message' => $contact_support_template |
52 'internal_message' => $contact_support_template, |
50 ), |
53 ), |
51 array( |
54 array( |
52 'id' => 'COULDNT_MAKE_IT_WORK', |
55 'id' => 'COULDNT_MAKE_IT_WORK', |
53 'text' => __( "I couldn't understand how to get it work", 'bestwebsoft' ), |
56 'text' => __( "I couldn't understand how to get it work", 'bestwebsoft' ), |
54 'input_type' => '', |
57 'input_type' => '', |
55 'input_placeholder' => '', |
58 'input_placeholder' => '', |
56 'internal_message' => $contact_support_template |
59 'internal_message' => $contact_support_template, |
57 ), |
60 ), |
58 array( |
61 array( |
59 'id' => 'FOUND_A_BETTER_PLUGIN', |
62 'id' => 'FOUND_A_BETTER_PLUGIN', |
60 'text' => __( 'I found a better plugin', 'bestwebsoft' ), |
63 'text' => __( 'I found a better plugin', 'bestwebsoft' ), |
61 'input_type' => 'textfield', |
64 'input_type' => 'textfield', |
62 'input_placeholder' => esc_attr__( "What's the plugin name?", 'bestwebsoft' ) |
65 'input_placeholder' => __( "What's the plugin name?", 'bestwebsoft' ), |
63 ), |
66 ), |
64 array( |
67 array( |
65 'id' => 'GREAT_BUT_NEED_SPECIFIC_FEATURE', |
68 'id' => 'GREAT_BUT_NEED_SPECIFIC_FEATURE', |
66 'text' => __( "The plugin is great, but I need specific feature that you don't support", 'bestwebsoft' ), |
69 'text' => __( "The plugin is great, but I need specific feature that you don't support", 'bestwebsoft' ), |
67 'input_type' => 'textarea', |
70 'input_type' => 'textarea', |
68 'input_placeholder' => esc_attr__( 'What feature?', 'bestwebsoft' ) |
71 'input_placeholder' => __( 'What feature?', 'bestwebsoft' ), |
69 ), |
72 ), |
70 array( |
73 array( |
71 'id' => 'NO_LONGER_NEEDED', |
74 'id' => 'NO_LONGER_NEEDED', |
72 'text' => __( 'I no longer need the plugin', 'bestwebsoft' ), |
75 'text' => __( 'I no longer need the plugin', 'bestwebsoft' ), |
73 'input_type' => '', |
76 'input_type' => '', |
74 'input_placeholder' => '' |
77 'input_placeholder' => '', |
75 ), |
78 ), |
76 array( |
79 array( |
77 'id' => 'TEMPORARY_DEACTIVATION', |
80 'id' => 'TEMPORARY_DEACTIVATION', |
78 'text' => __( "It's a temporary deactivation, I'm just debugging an issue", 'bestwebsoft' ), |
81 'text' => __( "It's a temporary deactivation, I'm just debugging an issue", 'bestwebsoft' ), |
79 'input_type' => '', |
82 'input_type' => '', |
80 'input_placeholder' => '' |
83 'input_placeholder' => '', |
81 ), |
84 ), |
82 array( |
85 array( |
83 'id' => 'OTHER', |
86 'id' => 'OTHER', |
84 'text' => __( 'Other', 'bestwebsoft' ), |
87 'text' => __( 'Other', 'bestwebsoft' ), |
85 'input_type' => 'textfield', |
88 'input_type' => 'textfield', |
86 'input_placeholder' => '' |
89 'input_placeholder' => '', |
87 ) |
90 ), |
88 ); |
91 ); |
89 |
92 |
90 $modal_html = '<div class="bws-modal bws-modal-deactivation-feedback"> |
93 $modal_html = '<div class="bws-modal bws-modal-deactivation-feedback"> |
91 <div class="bws-modal-dialog"> |
94 <div class="bws-modal-dialog"> |
92 <div class="bws-modal-body"> |
95 <div class="bws-modal-body"> |
93 <h2>' . __( 'Quick Feedback', 'bestwebsoft' ) . '</h2> |
96 <h2>' . __( 'Quick Feedback', 'bestwebsoft' ) . '</h2> |
94 <div class="bws-modal-panel active"> |
97 <div class="bws-modal-panel active"> |
95 <p>' . __( 'If you have a moment, please let us know why you are deactivating', 'bestwebsoft' ) . ":</p><ul>"; |
98 <p>' . __( 'If you have a moment, please let us know why you are deactivating', 'bestwebsoft' ) . ':</p><ul>'; |
96 |
99 |
97 foreach ( $reasons as $reason ) { |
100 foreach ( $reasons as $reason ) { |
98 $list_item_classes = 'bws-modal-reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' ); |
101 $list_item_classes = 'bws-modal-reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' ); |
99 |
102 |
100 if ( ! empty( $reason['internal_message'] ) ) { |
103 if ( ! empty( $reason['internal_message'] ) ) { |
101 $list_item_classes .= ' has-internal-message'; |
104 $list_item_classes .= ' has-internal-message'; |
102 $reason_internal_message = $reason['internal_message']; |
105 $reason_internal_message = $reason['internal_message']; |
103 } else { |
106 } else { |
104 $reason_internal_message = ''; |
107 $reason_internal_message = ''; |
105 } |
108 } |
106 |
109 |
349 */ |
352 */ |
350 if ( ! function_exists( 'bws_submit_uninstall_reason_action' ) ) { |
353 if ( ! function_exists( 'bws_submit_uninstall_reason_action' ) ) { |
351 function bws_submit_uninstall_reason_action() { |
354 function bws_submit_uninstall_reason_action() { |
352 global $bstwbsftwppdtplgns_options, $wp_version, $bstwbsftwppdtplgns_active_plugins, $current_user; |
355 global $bstwbsftwppdtplgns_options, $wp_version, $bstwbsftwppdtplgns_active_plugins, $current_user; |
353 |
356 |
354 wp_verify_nonce( $_REQUEST['bws_ajax_nonce'], 'bws_ajax_nonce' ); |
357 if ( isset( $_REQUEST['bws_ajax_nonce'] ) ) { |
355 |
358 |
356 $reason_id = isset( $_REQUEST['reason_id'] ) ? stripcslashes( sanitize_text_field( $_REQUEST['reason_id'] ) ) : ''; |
359 wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['bws_ajax_nonce'] ) ), 'bws_ajax_nonce' ); |
357 $basename = isset( $_REQUEST['plugin'] ) ? stripcslashes( sanitize_text_field( $_REQUEST['plugin'] ) ) : ''; |
360 |
358 |
361 $reason_id = isset( $_REQUEST['reason_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['reason_id'] ) ) : ''; |
359 if ( empty( $reason_id ) || empty( $basename ) ) { |
362 $basename = isset( $_REQUEST['plugin'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['plugin'] ) ) : ''; |
360 exit; |
363 |
361 } |
364 if ( empty( $reason_id ) || empty( $basename ) ) { |
362 |
365 exit; |
363 $reason_info = isset( $_REQUEST['reason_info'] ) ? stripcslashes( sanitize_text_field( $_REQUEST['reason_info'] ) ) : ''; |
366 } |
364 if ( ! empty( $reason_info ) ) { |
367 |
365 $reason_info = substr( $reason_info, 0, 255 ); |
368 $reason_info = isset( $_REQUEST['reason_info'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['reason_info'] ) ) : ''; |
366 } |
369 if ( ! empty( $reason_info ) ) { |
367 $is_anonymous = isset( $_REQUEST['is_anonymous'] ) && 1 == $_REQUEST['is_anonymous']; |
370 $reason_info = substr( $reason_info, 0, 255 ); |
368 |
371 } |
369 $options = array( |
372 $is_anonymous = isset( $_REQUEST['is_anonymous'] ) && 1 === intval( $_REQUEST['is_anonymous'] ); |
370 'product' => $basename, |
373 |
371 'reason_id' => $reason_id, |
374 $options = array( |
372 'reason_info' => $reason_info, |
375 'product' => $basename, |
373 ); |
376 'reason_id' => $reason_id, |
374 |
377 'reason_info' => $reason_info, |
375 if ( ! $is_anonymous ) { |
378 ); |
376 if ( ! isset( $bstwbsftwppdtplgns_options ) ) |
379 |
377 $bstwbsftwppdtplgns_options = ( is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); |
380 if ( ! $is_anonymous ) { |
378 |
381 if ( ! isset( $bstwbsftwppdtplgns_options ) ) { |
379 if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['usage_id'] ) ) { |
382 $bstwbsftwppdtplgns_options = ( is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' ); |
380 $options['usage_id'] = $bstwbsftwppdtplgns_options['track_usage']['usage_id']; |
383 } |
|
384 |
|
385 if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['usage_id'] ) ) { |
|
386 $options['usage_id'] = $bstwbsftwppdtplgns_options['track_usage']['usage_id']; |
|
387 } else { |
|
388 $options['usage_id'] = false; |
|
389 $options['url'] = get_bloginfo( 'url' ); |
|
390 $options['wp_version'] = $wp_version; |
|
391 $options['is_active'] = false; |
|
392 $options['version'] = $bstwbsftwppdtplgns_active_plugins[ $basename ]['Version']; |
|
393 } |
|
394 |
|
395 $options['email'] = $current_user->data->user_email; |
|
396 } |
|
397 |
|
398 /* send data */ |
|
399 $raw_response = wp_remote_post( |
|
400 'https://bestwebsoft.com/wp-content/plugins/products-statistics/deactivation-feedback/', |
|
401 array( |
|
402 'method' => 'POST', |
|
403 'body' => $options, |
|
404 'timeout' => 15, |
|
405 ) |
|
406 ); |
|
407 |
|
408 if ( ! is_wp_error( $raw_response ) && 200 === intval( wp_remote_retrieve_response_code( $raw_response ) ) ) { |
|
409 if ( ! $is_anonymous ) { |
|
410 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
411 |
|
412 if ( is_array( $response ) && ! empty( $response['usage_id'] ) && $response['usage_id'] !== $options['usage_id'] ) { |
|
413 $bstwbsftwppdtplgns_options['track_usage']['usage_id'] = $response['usage_id']; |
|
414 |
|
415 if ( is_multisite() ) { |
|
416 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
417 } else { |
|
418 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
419 } |
|
420 } |
|
421 } |
|
422 |
|
423 echo 'done'; |
381 } else { |
424 } else { |
382 $options['usage_id'] = false; |
425 echo wp_kses_data( $response->get_error_code() ) . ': ' . wp_kses_data( $response->get_error_message() ); |
383 $options['url'] = get_bloginfo( 'url' ); |
|
384 $options['wp_version'] = $wp_version; |
|
385 $options['is_active'] = false; |
|
386 $options['version'] = $bstwbsftwppdtplgns_active_plugins[ $basename ]['Version']; |
|
387 } |
426 } |
388 |
|
389 $options['email'] = $current_user->data->user_email; |
|
390 } |
|
391 |
|
392 /* send data */ |
|
393 $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/products-statistics/deactivation-feedback/', array( |
|
394 'method' => 'POST', |
|
395 'body' => $options, |
|
396 'timeout' => 15, |
|
397 ) ); |
|
398 |
|
399 if ( ! is_wp_error( $raw_response ) && 200 == wp_remote_retrieve_response_code( $raw_response ) ) { |
|
400 if ( ! $is_anonymous ) { |
|
401 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) ); |
|
402 |
|
403 if ( is_array( $response ) && ! empty( $response['usage_id'] ) && $response['usage_id'] != $options['usage_id'] ) { |
|
404 $bstwbsftwppdtplgns_options['track_usage']['usage_id'] = $response['usage_id']; |
|
405 |
|
406 if ( is_multisite() ) |
|
407 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
408 else |
|
409 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options ); |
|
410 } |
|
411 } |
|
412 |
|
413 echo 'done'; |
|
414 } else { |
|
415 echo $response->get_error_code() . ': ' . $response->get_error_message(); |
|
416 } |
427 } |
417 exit; |
428 exit; |
418 } |
429 } |
419 } |
430 } |
420 |
431 |