| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 |
|
| 4 |
if ( ! class_exists( 'ewdotpDeactivationSurvey' ) ) { |
| 5 |
/** |
| 6 |
* Class to handle plugin deactivation survey |
| 7 |
* |
| 8 |
* @since 3.0.0 |
| 9 |
*/ |
| 10 |
class ewdotpDeactivationSurvey { |
| 11 |
|
| 12 |
public function __construct() { |
| 13 |
add_action( 'current_screen', array( $this, 'maybe_add_survey' ) ); |
| 14 |
} |
| 15 |
|
| 16 |
public function maybe_add_survey() { |
| 17 |
if ( in_array( get_current_screen()->id, array( 'plugins', 'plugins-network' ), true) ) { |
| 18 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_deactivation_scripts') ); |
| 19 |
add_action( 'admin_footer', array( $this, 'add_deactivation_html') ); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
public function enqueue_deactivation_scripts() { |
| 24 |
wp_enqueue_style( 'ewd-otp-deactivation-css', EWD_OTP_PLUGIN_URL . '/assets/css/plugin-deactivation.css' ); |
| 25 |
wp_enqueue_script( 'ewd-otp-deactivation-js', EWD_OTP_PLUGIN_URL . '/assets/js/plugin-deactivation.js', array( 'jquery' ) ); |
| 26 |
|
| 27 |
wp_localize_script( 'ewd-otp-deactivation-js', 'ewd_otp_deactivation_data', array( 'site_url' => site_url() ) ); |
| 28 |
} |
| 29 |
|
| 30 |
public function add_deactivation_html() { |
| 31 |
|
| 32 |
$install_time = get_option( 'ewd-otp-installation-time' ); |
| 33 |
|
| 34 |
$options = array( |
| 35 |
1 => array( |
| 36 |
'title' => esc_html__( 'I no longer need the plugin', 'order-tracking' ), |
| 37 |
), |
| 38 |
2 => array( |
| 39 |
'title' => esc_html__( 'I\'m switching to a different plugin', 'order-tracking' ), |
| 40 |
'details' => esc_html__( 'Please share which plugin', 'order-tracking' ), |
| 41 |
), |
| 42 |
3 => array( |
| 43 |
'title' => esc_html__( 'I couldn\'t get the plugin to work', 'order-tracking' ), |
| 44 |
'details' => esc_html__( 'Please share what wasn\'t working', 'order-tracking' ), |
| 45 |
), |
| 46 |
4 => array( |
| 47 |
'title' => esc_html__( 'It\'s a temporary deactivation', 'order-tracking' ), |
| 48 |
), |
| 49 |
5 => array( |
| 50 |
'title' => esc_html__( 'Other', 'order-tracking' ), |
| 51 |
'details' => esc_html__( 'Please share the reason', 'order-tracking' ), |
| 52 |
), |
| 53 |
); |
| 54 |
?> |
| 55 |
<div class="ewd-otp-deactivate-survey-modal" id="ewd-otp-deactivate-survey-order-tracking"> |
| 56 |
<div class="ewd-otp-deactivate-survey-wrap"> |
| 57 |
<form class="ewd-otp-deactivate-survey" method="post" data-installtime="<?php echo $install_time; ?>"> |
| 58 |
<span class="ewd-otp-deactivate-survey-title"><span class="dashicons dashicons-testimonial"></span><?php echo ' ' . __( 'Quick Feedback', 'order-tracking' ); ?></span> |
| 59 |
<span class="ewd-otp-deactivate-survey-desc"><?php echo __('If you have a moment, please share why you are deactivating Order Tracking:', 'order-tracking' ); ?></span> |
| 60 |
<div class="ewd-otp-deactivate-survey-options"> |
| 61 |
<?php foreach ( $options as $id => $option ) : ?> |
| 62 |
<div class="ewd-otp-deactivate-survey-option"> |
| 63 |
<label for="ewd-otp-deactivate-survey-option-order-tracking-<?php echo $id; ?>" class="ewd-otp-deactivate-survey-option-label"> |
| 64 |
<input id="ewd-otp-deactivate-survey-option-order-tracking-<?php echo $id; ?>" class="ewd-otp-deactivate-survey-option-input" type="radio" name="code" value="<?php echo $id; ?>" /> |
| 65 |
<span class="ewd-otp-deactivate-survey-option-reason"><?php echo $option['title']; ?></span> |
| 66 |
</label> |
| 67 |
<?php if ( ! empty( $option['details'] ) ) : ?> |
| 68 |
<input class="ewd-otp-deactivate-survey-option-details" type="text" placeholder="<?php echo $option['details']; ?>" /> |
| 69 |
<?php endif; ?> |
| 70 |
</div> |
| 71 |
<?php endforeach; ?> |
| 72 |
</div> |
| 73 |
<div class="ewd-otp-deactivate-survey-footer"> |
| 74 |
<button type="submit" class="ewd-otp-deactivate-survey-submit button button-primary button-large"><?php _e('Submit and Deactivate', 'order-tracking' ); ?></button> |
| 75 |
<a href="#" class="ewd-otp-deactivate-survey-deactivate"><?php _e('Skip and Deactivate', 'order-tracking' ); ?></a> |
| 76 |
</div> |
| 77 |
</form> |
| 78 |
</div> |
| 79 |
</div> |
| 80 |
<?php |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
} |