| 1 |
<?php |
| 2 |
/** |
| 3 |
* Add exit-survey logic to plugins-page. |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; |
| 8 |
} |
| 9 |
|
| 10 |
class autoptimizeExitSurvey |
| 11 |
{ |
| 12 |
function __construct() { |
| 13 |
global $pagenow; |
| 14 |
|
| 15 |
if ( $pagenow != 'plugins.php' ) { |
| 16 |
return; |
| 17 |
} |
| 18 |
|
| 19 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_survey_scripts' ) ); |
| 20 |
add_action( 'admin_footer', array( $this, 'render_survey_model' ) ); |
| 21 |
} |
| 22 |
|
| 23 |
function enqueue_survey_scripts() { |
| 24 |
wp_enqueue_script( 'ao_exit_survey', plugins_url( '/static/exit-survey/exit-survey.js', __FILE__ ), array( |
| 25 |
'jquery' |
| 26 |
), AUTOPTIMIZE_PLUGIN_VERSION ); |
| 27 |
|
| 28 |
wp_enqueue_style( 'ao_exit_survey', plugins_url( '/static/exit-survey/exit-survey.css', __FILE__ ), null, AUTOPTIMIZE_PLUGIN_VERSION ); |
| 29 |
} |
| 30 |
|
| 31 |
function render_survey_model() { |
| 32 |
global $wp_version; |
| 33 |
|
| 34 |
$data = array( |
| 35 |
"home" => home_url(), |
| 36 |
"dest" => 'aHR0cHM6Ly9taXNjLm9wdGltaXppbmdtYXR0ZXJzLmNvbS9hb19leGl0X3N1cnZleS9pbmRleC5waHA=' |
| 37 |
); |
| 38 |
?> |
| 39 |
|
| 40 |
<div class="ao-plugin-uninstall-feedback-popup ao-feedback" id="ao_uninstall_feedback_popup" data-modal="<?php echo base64_encode( json_encode( $data ) ) ?>"> |
| 41 |
<div class="popup--header"> |
| 42 |
<h5><?php _e( 'Sorry to see you go, we would appreciate if you let us know why you\'re deactivating Autoptimize!', 'autoptimize' ); ?></h5> |
| 43 |
</div><!--/.popup--header--> |
| 44 |
<div class="popup--body"> |
| 45 |
<ul class="popup--form"> |
| 46 |
<li ao-option-id="5"> |
| 47 |
<input type="radio" name="ao-deactivate-option" id="ao_feedback5"> |
| 48 |
<label for="ao_feedback5"> |
| 49 |
<?php _e( 'I don\'t see a performance improvement.', 'autoptimize' ); ?> |
| 50 |
</label> |
| 51 |
<p class="last-attempt"><?php _e( 'As Autoptimize does not do page caching, you might have to install e.g. KeyCDN Cache Enabler or WP Super Cache as well. Feel free to create a topic on <a href="https://wordpress.org/support/plugin/autoptimize/#new-topic-0" target="_blank">the support forum here</a> to get pointers on how get the most out of Autoptimize!', 'autoptimize' ); ?></p> |
| 52 |
</li> |
| 53 |
<li ao-option-id="6"> |
| 54 |
<input type="radio" name="ao-deactivate-option" id="ao_feedback6"> |
| 55 |
<label for="ao_feedback6" data-reason="broke site"> |
| 56 |
<?php _e( 'It broke my site.', 'autoptimize' ); ?> |
| 57 |
</label> |
| 58 |
<p class="last-attempt"><?php _e( 'Almost all problems can be fixed with the right configuration, have a look at <a href="https://wordpress.org/plugins/autoptimize/#faq" target="_blank">the FAQ</a> or create a topic on <a href="https://wordpress.org/support/plugin/autoptimize/#new-topic-0" target="_blank">the support forum here</a>!', 'autoptimize' ); ?></p> |
| 59 |
<li ao-option-id="4"> |
| 60 |
<input type="radio" name="ao-deactivate-option" id="ao_feedback4"> |
| 61 |
<label for="ao_feedback4" data-reason="found better"> |
| 62 |
<?php _e( 'I found a better solution.', 'autoptimize' ); ?> |
| 63 |
</label> |
| 64 |
<li ao-option-id="3"> |
| 65 |
<input type="radio" name="ao-deactivate-option" id="ao_feedback3"> |
| 66 |
<label for="ao_feedback3" data-reason="just temporarily"> |
| 67 |
<?php _e( 'I\'m just disabling temporarily.', 'autoptimize' ); ?> |
| 68 |
</label> |
| 69 |
<li ao-option-id="999"> |
| 70 |
<input type="radio" name="ao-deactivate-option" id="ao_feedback999"> |
| 71 |
<label for="ao_feedback999" data-reason="other"> |
| 72 |
<?php _e( 'Other (please specify below)', 'autoptimize' ); ?> </label> |
| 73 |
<textarea width="100%" rows="2" name="comments" placeholder="What can we do better?"></textarea></li> |
| 74 |
<hr /> |
| 75 |
<li ao-option-id="998"> |
| 76 |
<label for="ao_feedback998" data-reason="other detail"> |
| 77 |
<?php _e( 'If you want to be contacted about or get help with Autoptimize, leave your email here (we never spam).', 'autoptimize' ); ?> |
| 78 |
</label> |
| 79 |
<input type="email" name="ao-deactivate-option" id="ao_feedback998" placeholder="mymail@domain.xyz"> |
| 80 |
</li> |
| 81 |
</ul> |
| 82 |
</div><!--/.popup--body--> |
| 83 |
<div class="popup--footer"> |
| 84 |
<div class="actions"> |
| 85 |
<a href="#" class="info-disclosure-link"><?php _e( 'What info do we collect?', 'autoptimize' ); ?></a> |
| 86 |
<div class="info-disclosure-content"><p><?php _e( 'Below is a detailed view of all data that Optimizing Matters will receive if |
| 87 |
you fill in this survey. Your email address is only shared if you explicitly fill it in, your IP addres is never sent.', 'autoptimize' ); ?></p> |
| 88 |
<ul> |
| 89 |
<li><strong><?php _e( 'Plugin version', 'autoptimize' ); ?> </strong> <code id="ao_plugin_version"> <?php echo AUTOPTIMIZE_PLUGIN_VERSION ?> </code></li> |
| 90 |
<li><strong><?php _e( 'WordPress version', 'autoptimize' ); ?> </strong> <code id="core_version"> <?php echo $wp_version ?> </code></li> |
| 91 |
<li><strong><?php _e( 'Current website:', 'autoptimize' ); ?></strong> <code> <?php echo trailingslashit(get_site_url()) ?> </code></li> |
| 92 |
<li><strong><?php _e( 'Uninstall reason', 'autoptimize' ); ?> </strong> <i> <?php _e( 'Selected reason from the above survey', 'autoptimize' ); ?> </i></li> |
| 93 |
</ul> |
| 94 |
</div> |
| 95 |
<div class="buttons"> |
| 96 |
<input type="submit" |
| 97 |
name="ao-deactivate-no" |
| 98 |
id="ao-deactivate-no" |
| 99 |
class="button" |
| 100 |
value="Just Deactivate"> |
| 101 |
<input type="submit" |
| 102 |
name="ao-deactivate-cancel" |
| 103 |
id="ao-deactivate-cancel" |
| 104 |
class="button" |
| 105 |
value="Cancel"> |
| 106 |
<input type="submit" |
| 107 |
name="ao-deactivate-yes" |
| 108 |
id="ao-deactivate-yes" |
| 109 |
class="button button-primary" |
| 110 |
value="Submit & Deactivate" |
| 111 |
data-after-text="Submit & Deactivate" |
| 112 |
disabled="1"></div> |
| 113 |
|
| 114 |
</div><!--/.actions--> |
| 115 |
</div><!--/.popup--footer--> |
| 116 |
</div> |
| 117 |
<?php } |
| 118 |
} |
| 119 |
|