-
Notifications
You must be signed in to change notification settings - Fork 117
Add deactivation modal #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7a8d963
Add deactivation modal
timotei-litespeed 851880b
Merge branch 'dev' into Deactivate-modal
timotei-litespeed 78f7226
Merge branch 'dev' into Deactivate-modal
timotei-litespeed 83c19ee
Modal deactivation tpl format + JS move
timotei-litespeed 2c7fed8
Move settings and table remove to uninstall
timotei-litespeed 485c762
Remove checkbox to delete settings
timotei-litespeed 1c181ce
Wording review fix
timotei-litespeed 61571de
Review fixes
timotei-litespeed 159dbc1
Files review
timotei-litespeed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
<?php | ||
/** | ||
* LiteSpeed Cache Deactivation Modal | ||
* | ||
* Renders the deactivation modal interface for LiteSpeed Cache, allowing users to send reason of deactivation. | ||
* | ||
* @package LiteSpeed | ||
* @since 7.3 | ||
*/ | ||
|
||
namespace LiteSpeed; | ||
|
||
defined( 'WPINC' ) || exit; | ||
|
||
// Modal data | ||
$_title = esc_html__('Deactivate LiteSpeed Cache', 'litespeed'); | ||
$_id = 'litespeed-modal-deactivate'; | ||
|
||
$reasons = array( | ||
array( | ||
'value' => 'Temporary', | ||
'text' => esc_html__('The deactivation is temporary', 'litespeed-cache'), | ||
'id' => 'temp', | ||
'selected' => true, | ||
), | ||
array( | ||
'value' => 'Performance worse', | ||
'text' => esc_html__('Site performance is worse', 'litespeed-cache'), | ||
'id' => 'performance', | ||
), | ||
array( | ||
'value' => 'Plugin complicated', | ||
'text' => esc_html__('Plugin is too complicated', 'litespeed-cache'), | ||
'id' => 'complicated', | ||
), | ||
array( | ||
'value' => 'Other', | ||
'text' => esc_html__('Other', 'litespeed-cache'), | ||
'id' => 'other', | ||
), | ||
); | ||
?> | ||
<div style="display: none"> | ||
<div id="litespeed-deactivation" class="iziModal"> | ||
<div id="litespeed-modal-deactivate"> | ||
<form id="litespeed-deactivation-form" method="post"> | ||
<p><?php esc_attr_e('Why are you deactivating the plugin?', 'litespeed-cache'); ?></p> | ||
<div class="deactivate-reason-wrapper"> | ||
<?php | ||
foreach ($reasons as $reason) { | ||
echo '<label for="litespeed-deactivate-reason-' . | ||
esc_html__( $reason['id'] ) . | ||
'"> | ||
<input type="radio" | ||
id="litespeed-deactivate-reason-' . | ||
esc_html__( $reason['id'] ) . | ||
'" | ||
value="' . | ||
esc_html__( $reason['value'] ) . | ||
'" | ||
' . | ||
(isset($reason['selected']) && $reason['selected'] ? ' checked="checked"' : '') . | ||
' | ||
name="litespeed-reason" | ||
/> | ||
' . | ||
esc_html__( $reason['text'] ) . | ||
' | ||
</label>'; | ||
} | ||
?> | ||
</div> | ||
<div class="deactivate-clear-settings-wrapper"> | ||
<i style="font-size: 0.9em;"> | ||
<?php | ||
esc_html_e('On uninstall, all plugin settings will be deleted.', 'litespeed-cache'); | ||
?> | ||
</i> | ||
<br /> | ||
<i style="font-size: 0.9em;"> | ||
|
||
<?php | ||
printf( | ||
esc_html__('If you have used Image Optimization, please %sDestroy All Optimization Data%s first. NOTE: this does not remove your optimized images.', 'litespeed-cache'), | ||
'<a href="admin.php?page=litespeed-img_optm#litespeed-imageopt-destroy" target="_blank">', | ||
'</a>' | ||
); | ||
?> | ||
</i> | ||
</div> | ||
<div class="deactivate-actions"> | ||
<input | ||
type="button" | ||
id="litespeed-deactivation-form-cancel" | ||
class="button litespeed-btn-warning" | ||
value="<?php esc_attr_e('Cancel', 'litespeed-cache'); ?>" | ||
title="<?php esc_attr_e('Close popup', 'litespeed-cache'); ?>" /> | ||
<input | ||
type="submit" | ||
id="litespeed-deactivation-form-submit" | ||
class="button button-primary" | ||
value="<?php esc_attr_e('Deactivate', 'litespeed-cache'); ?>" | ||
title="<?php esc_attr_e('Deactivate plugin', 'litespeed-cache'); ?>" /> | ||
<br /> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
<script> | ||
(function ($) { | ||
'use strict'; | ||
jQuery(document).ready(function () { | ||
var lscId = '<?php echo home_url(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'; | ||
var modalesc_attr_element = $('#litespeed-deactivation'); | ||
var deactivateesc_attr_element = $('#deactivate-litespeed-cache'); | ||
|
||
if (deactivateesc_attr_element.length > 0 && modalesc_attr_element.length > 0) { | ||
// Variables | ||
var modal_formElement = $('#litespeed-deactivation-form'); | ||
|
||
deactivateesc_attr_element.on('click', function (e) { | ||
e.preventDefault(); | ||
e.stopImmediatePropagation(); | ||
modal_formElement.attr('action', decodeURI($(this).attr('href'))); | ||
modalesc_attr_element.iziModal({ | ||
radius: '.5rem', | ||
width: 550, | ||
autoOpen: true, | ||
}); | ||
}); | ||
|
||
$(document).on('submit', '#litespeed-deactivation-form', function (e) { | ||
e.preventDefault(); | ||
$('#litespeed-deactivation-form-submit').attr('disabled', true); | ||
var container = $('#litespeed-deactivation-form'); | ||
|
||
// Save selected data | ||
var data = { | ||
id: lscId, | ||
siteLink: window.location.hostname, | ||
reason: $(container).find('[name=litespeed-reason]:checked').val() | ||
}; | ||
|
||
$.ajax({ | ||
url: 'https://wpapi.quic.cloud/survey', | ||
dataType: 'json', | ||
method: 'POST', | ||
cache: false, | ||
data: data, | ||
beforeSend: function (xhr) { | ||
//xhr.setRequestHeader('X-WP-Nonce', litespeed_data.nonce); | ||
}, | ||
success: function (data) { | ||
console.log('QC data sent.'); | ||
}, | ||
error: function (xhr, error) { | ||
console.log('Error sending data to QC.'); | ||
}, | ||
}); | ||
|
||
$('#litespeed-deactivation-form')[0].submit(); | ||
}); | ||
$(document).on('click', '#litespeed-deactivation-form-cancel', function (e) { | ||
modalesc_attr_element.iziModal('close'); | ||
}); | ||
} | ||
}); | ||
})(jQuery); | ||
</script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.