first commit
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
<div id="analyst-deactivate-modal" class="analyst-modal" style="display: none">
|
||||
<div class="analyst-modal-content" style="width: 500px">
|
||||
<div class="analyst-disable-modal-mask" id="analyst-disable-deactivate-modal-mask" style="display: none"></div>
|
||||
<div style="display: flex">
|
||||
<div class="analyst-install-image-block" style="width: 80px">
|
||||
<img src="<?php echo $pencilImage; ?>"/>
|
||||
</div>
|
||||
<div class="analyst-install-description-block" style="padding-left: 20px">
|
||||
<strong class="analyst-modal-header">Why do you deactivate?</strong>
|
||||
<div class="analyst-install-description-text" style="padding-top: 2px">
|
||||
Please let us know, so we can improve it! Thank you <img class="analyst-smile-image" src="<?php echo $smileImage; ?>" alt="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<ul id="analyst-deactivation-reasons">
|
||||
<li>
|
||||
<label>
|
||||
<span>
|
||||
<input type="radio" name="deactivation-reason">
|
||||
</span>
|
||||
<span class="question" data-question="I couldn't understand how to make it work">I couldn't understand how to make it work</span>
|
||||
</label>
|
||||
</li>
|
||||
<li data-input-type="textarea" data-input-placeholder="What should have worked, but didn’t?">
|
||||
<label>
|
||||
<span>
|
||||
<input type="radio" name="deactivation-reason">
|
||||
</span>
|
||||
<span class="question" data-question="The plugin didn't work as expected">The plugin didn't work as expected</span>
|
||||
</label>
|
||||
<div class="question-answer"></div>
|
||||
</li>
|
||||
<li data-input-type="input" data-input-placeholder="What is the plugin name?">
|
||||
<label>
|
||||
<span>
|
||||
<input type="radio" name="deactivation-reason">
|
||||
</span>
|
||||
<span class="question" data-question="I found a better plugin">I found a better plugin</span>
|
||||
</label>
|
||||
<div class="question-answer"></div>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<span>
|
||||
<input type="radio" name="deactivation-reason">
|
||||
</span>
|
||||
<span class="question" data-question="It's a temporary deactivation">It's a temporary deactivation</span>
|
||||
</label>
|
||||
<div class="question-answer"></div>
|
||||
</li>
|
||||
<li data-input-type="textarea" data-input-placeholder="Please provide the reason of deactivation">
|
||||
<label>
|
||||
<span>
|
||||
<input type="radio" name="deactivation-reason">
|
||||
</span>
|
||||
<span class="question" data-question="Other">Other</span>
|
||||
</label>
|
||||
<div class="question-answer"></div>
|
||||
</li>
|
||||
</ul>
|
||||
<p id="analyst-deactivation-error" style="color: #dc3232; font-size: 16px; display: none">Please let us know the reason for de-activation. Thank you!</p>
|
||||
</div>
|
||||
<div>
|
||||
<button class="analyst-btn-grey" id="analyst-disabled-plugin-action">Deactivate</button>
|
||||
</div>
|
||||
<div class="" style="text-align: center; font-size: 18px; padding-top: 10px">
|
||||
<button class="analyst-btn-secondary-ghost analyst-deactivate-modal-close" style="color: #cccccc">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function ($) {
|
||||
$('.deactivate').click(function (e) {
|
||||
var anchor = $(this).find('[analyst-plugin-id]')
|
||||
var pluginId = anchor.attr('analyst-plugin-id')
|
||||
var isOptedIn = anchor.attr('analyst-plugin-opted-in') === '1'
|
||||
|
||||
// Do not ask for reason if not opted in
|
||||
if (!isOptedIn) {
|
||||
return
|
||||
}
|
||||
|
||||
e.preventDefault()
|
||||
|
||||
$('#analyst-deactivate-modal')
|
||||
.attr({
|
||||
'analyst-plugin-id': pluginId,
|
||||
'analyst-redirect-url': $(this).find('a').attr('href')
|
||||
})
|
||||
.show()
|
||||
})
|
||||
|
||||
$('.analyst-deactivate-modal-close').click(function () {
|
||||
$('#analyst-deactivate-modal').hide()
|
||||
})
|
||||
|
||||
$('#analyst-deactivation-reasons input[name="deactivation-reason"]').change(function () {
|
||||
$('.question-answer').empty()
|
||||
|
||||
var root = $('#analyst-deactivation-reasons input[name="deactivation-reason"]:checked').parents('li')
|
||||
|
||||
$('#analyst-deactivation-error').hide()
|
||||
|
||||
if (!root.attr('data-input-type')) return
|
||||
|
||||
var reasonInput = $('<' + root.attr('data-input-type') + '/>').attr({placeholder: root.attr('data-input-placeholder'), class: 'reason-answer'})
|
||||
|
||||
root.find('.question-answer').append(reasonInput)
|
||||
})
|
||||
|
||||
$('#analyst-disabled-plugin-action').click(function () {
|
||||
var pluginId = $('#analyst-deactivate-modal').attr('analyst-plugin-id')
|
||||
var pluginDeactivationUrl = $('#analyst-deactivate-modal').attr('analyst-redirect-url')
|
||||
|
||||
var root = $('#analyst-deactivation-reasons input[name="deactivation-reason"]:checked').parents('li');
|
||||
|
||||
var reason = root.find('.question-answer .reason-answer').val();
|
||||
|
||||
var question = root.find('.question').attr('data-question').trim()
|
||||
|
||||
var $errorBlock = $('#analyst-deactivation-error')
|
||||
|
||||
if (!question) {
|
||||
return $errorBlock.show()
|
||||
}
|
||||
|
||||
$errorBlock.hide()
|
||||
|
||||
var data = {
|
||||
action: 'analyst_plugin_deactivate_' + pluginId,
|
||||
question: question,
|
||||
nonce: analyst_opt_localize.nonce
|
||||
}
|
||||
|
||||
if (reason) {
|
||||
data['reason'] = reason.trim();
|
||||
}
|
||||
|
||||
$(this).attr('disabled', true).text('Deactivating...');
|
||||
|
||||
$('#analyst-disable-deactivate-modal-mask').show();
|
||||
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
method: 'POST',
|
||||
data: data
|
||||
}).done(function () {
|
||||
window.location.href = pluginDeactivationUrl
|
||||
|
||||
$('#analyst-disable-deactivate-modal-mask').hide();
|
||||
})
|
||||
})
|
||||
|
||||
})(jQuery)
|
||||
</script>
|
||||
@@ -0,0 +1,117 @@
|
||||
<div id="analyst-install-modal" class="analyst-modal" style="display: none" analyst-plugin-id="<?php echo $pluginToInstall; ?>">
|
||||
<div class="analyst-modal-content" style="width: 450px">
|
||||
<div class="analyst-disable-modal-mask" id="analyst-disable-install-modal-mask" style="display: none"></div>
|
||||
<div style="display: flex">
|
||||
<div class="analyst-install-image-block">
|
||||
<img src="<?php echo $shieldImage; ?>"/>
|
||||
</div>
|
||||
<div class="analyst-install-description-block">
|
||||
<strong class="analyst-modal-header">Stay on the safe side</strong>
|
||||
<p class="analyst-install-description-text">Receive our plugin’s alerts in
|
||||
case of <strong>critical security</strong>, feature & special deal
|
||||
updates and allow non-sensitive
|
||||
diagnostic tracking.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="analyst-modal-def-top-padding">
|
||||
<button class="analyst-btn-success" id="analyst-install-action">Allow & Continue ></button>
|
||||
</div>
|
||||
<div class="analyst-modal-def-top-padding" id="analyst-permissions-block" style="display: none">
|
||||
<span>You’re granting these permissions:</span>
|
||||
<ul class="analyst-install-permissions-list">
|
||||
<li><strong>Your profile information</strong> (name and email) </li>
|
||||
<li><strong>Your site information</strong> (URL, WP version, PHP info, plugins & themes)</li>
|
||||
<li><strong>Plugin notices</strong> (updates, announcements, marketing, no spam)</li>
|
||||
<li><strong>Plugin events</strong> (activation, deactivation and uninstall)</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="analyst-install-footer analyst-modal-def-top-padding">
|
||||
<span class="analyst-action-text" id="analyst-permissions-toggle">Learn more</span>
|
||||
<span id="analyst-powered-by" style="display: none;">Powered by <a href="https://sellcodes.com/blog/wordpress-feedback-system-for-plugin-creators/?utm_source=optin_screen" target="_blank" class="analyst-link">Sellcodes.com</a></span>
|
||||
<span class="analyst-action-text analyst-install-modal-close" id="analyst-install-skip">Skip</span>
|
||||
</div>
|
||||
<div id="analyst-install-error" class="analyst-modal-def-top-padding" style="display: none; text-align: center">
|
||||
<span style="color: #dc3232; font-size: 16px">Service unavailable. Please try again later</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function ($) {
|
||||
|
||||
var installPlugin = function (pluginId) {
|
||||
var $error = $('#analyst-install-error')
|
||||
|
||||
$error.hide()
|
||||
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
method: 'POST',
|
||||
data: {
|
||||
action: 'analyst_install_' + pluginId,
|
||||
nonce: analyst_opt_localize.nonce
|
||||
},
|
||||
success: function (data) {
|
||||
if (data && !data.success) {
|
||||
//error
|
||||
$('#analyst-install-modal').hide()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
window.location.reload()
|
||||
},
|
||||
error: function () {
|
||||
$('#analyst-install-modal').hide()
|
||||
}
|
||||
}).done(function () {
|
||||
$('#analyst-disable-install-modal-mask').hide()
|
||||
|
||||
$('#analyst-install-action')
|
||||
.attr('disabled', false)
|
||||
.text('Allow & Continue >')
|
||||
})
|
||||
}
|
||||
|
||||
if ($('#analyst-install-modal').attr('analyst-plugin-id')) {
|
||||
$('#analyst-install-modal').show()
|
||||
}
|
||||
|
||||
|
||||
$('.analyst-install-modal-close').click(function () {
|
||||
$('#analyst-install-modal').hide()
|
||||
})
|
||||
|
||||
$('#analyst-install-action').click(function () {
|
||||
var pluginId = $('#analyst-install-modal').attr('analyst-plugin-id')
|
||||
|
||||
$('#analyst-install-action')
|
||||
.attr('disabled', true)
|
||||
.text('Please wait...')
|
||||
|
||||
$('#analyst-disable-install-modal-mask').show()
|
||||
|
||||
installPlugin(pluginId)
|
||||
})
|
||||
|
||||
$('#analyst-permissions-toggle').click(function () {
|
||||
var isVisible = $('#analyst-permissions-block').toggle().is(':visible')
|
||||
|
||||
isVisible ? $(this).text('Close section') : $(this).text('Learn more')
|
||||
|
||||
var poweredBy = $('#analyst-powered-by')
|
||||
isVisible ? poweredBy.show() : poweredBy.hide()
|
||||
})
|
||||
|
||||
$('#analyst-install-skip').click(function () {
|
||||
var pluginId = $('#analyst-install-modal').attr('analyst-plugin-id')
|
||||
|
||||
$.post(ajaxurl, {
|
||||
action: 'analyst_skip_install_' + pluginId,
|
||||
nonce: analyst_opt_localize.nonce
|
||||
}).done(function () {
|
||||
$('#analyst-install-modal').hide()
|
||||
})
|
||||
})
|
||||
})(jQuery)
|
||||
</script>
|
||||
@@ -0,0 +1,10 @@
|
||||
<div class="notice notice-success analyst-notice">
|
||||
<p>
|
||||
<strong class="analyst-plugin-name"><?php echo $notice->getPluginName(); ?></strong>
|
||||
<?php echo $notice->getBody(); ?>
|
||||
</p>
|
||||
|
||||
<button type="button" class="analyst-notice-dismiss notice-dismiss" analyst-notice-id="<?php echo $notice->getId(); ?>">
|
||||
<span class="screen-reader-text">Dismiss this notice.</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -0,0 +1,61 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
(function ($) {
|
||||
var isOptingIn = false
|
||||
|
||||
$('#analyst-opt-in-modal').appendTo($('body'))
|
||||
|
||||
var makeOptIn = function (pluginId) {
|
||||
if (isOptingIn) return
|
||||
|
||||
isOptingIn = true
|
||||
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
method: 'POST',
|
||||
data: {
|
||||
action: 'analyst_opt_in_' + pluginId,
|
||||
nonce: analyst_opt_localize.nonce
|
||||
},
|
||||
success: function () {
|
||||
$('#analyst-opt-in-modal').hide()
|
||||
|
||||
isOptingIn = false
|
||||
|
||||
var optOutAction = $('<a />').attr({
|
||||
class: 'analyst-action-opt analyst-opt-out',
|
||||
'analyst-plugin-id': pluginId,
|
||||
'analyst-plugin-signed': '1'
|
||||
})
|
||||
.text('Opt Out')
|
||||
$('.analyst-opt-in[analyst-plugin-id="'+ pluginId +'"').replaceWith(optOutAction)
|
||||
|
||||
$('[analyst-plugin-id="' + pluginId + '"').attr('analyst-plugin-opted-in', 1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$(document).on('click', '.analyst-opt-in:not([loading])', function() {
|
||||
var pluginId = $(this).attr('analyst-plugin-id')
|
||||
var isSigned = $(this).attr('analyst-plugin-signed') === '1'
|
||||
|
||||
if (!isSigned) {
|
||||
$('#analyst-install-modal')
|
||||
.attr('analyst-plugin-id', pluginId)
|
||||
.show()
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$('#analyst-install-modal').attr({'analyst-plugin-id': pluginId})
|
||||
|
||||
$(this).attr('loading', true).text('Opting In...')
|
||||
|
||||
makeOptIn(pluginId);
|
||||
})
|
||||
|
||||
$('.opt-in-modal-close').click(function () {
|
||||
$('#analyst-opt-in-modal').hide()
|
||||
})
|
||||
})(jQuery)
|
||||
</script>
|
||||
@@ -0,0 +1,110 @@
|
||||
<div id="analyst-opt-out-modal" class="analyst-modal" style="display: none">
|
||||
<div class="analyst-modal-content" style="width: 600px">
|
||||
<div class="analyst-disable-modal-mask" id="analyst-disable-opt-out-modal-mask" style="display: none"></div>
|
||||
<div style="display: flex">
|
||||
<div class="analyst-install-image-block" style="width: 120px">
|
||||
<img src="<?php echo $shieldImage; ?>"/>
|
||||
</div>
|
||||
<div class="analyst-install-description-block">
|
||||
<strong class="analyst-modal-header">By opting out, we cannot alert you anymore in case of important security updates.</strong>
|
||||
<p class="analyst-install-description-text">
|
||||
In addition, we won’t get pointers how to further improve the plugin based on your integration with our plugin.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="analyst-modal-def-top-padding">
|
||||
<button class="analyst-btn-success opt-out-modal-close">Ok, don't opt out</button>
|
||||
</div>
|
||||
<div class="analyst-modal-def-top-padding" style="text-align: center;">
|
||||
<button class="analyst-btn-secondary-ghost" id="opt-out-action">Opt out</button>
|
||||
</div>
|
||||
<div id="analyst-opt-out-error" class="analyst-modal-def-top-padding" style="display: none;">
|
||||
<span style="color: #dc3232; font-size: 16px">Service unavailable. Please try again later</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function ($) {
|
||||
var isOptingOut = false
|
||||
|
||||
$('#analyst-opt-out-modal').appendTo($('body'))
|
||||
|
||||
$(document).on('click', '.analyst-opt-out', function() {
|
||||
var pluginId = $(this).attr('analyst-plugin-id')
|
||||
|
||||
$('#analyst-opt-out-modal')
|
||||
.attr({'analyst-plugin-id': pluginId})
|
||||
.show()
|
||||
})
|
||||
|
||||
$('.opt-out-modal-close').click(function () {
|
||||
$('#analyst-opt-out-modal').hide()
|
||||
})
|
||||
|
||||
$('#opt-out-action').click(function () {
|
||||
if (isOptingOut) return
|
||||
|
||||
var $mask = $('#analyst-disable-opt-out-modal-mask')
|
||||
var $error = $('#analyst-opt-out-error')
|
||||
|
||||
var pluginId = $('#analyst-opt-out-modal').attr('analyst-plugin-id')
|
||||
|
||||
$mask.show()
|
||||
$error.hide()
|
||||
|
||||
var self = this
|
||||
|
||||
isOptingOut = true
|
||||
|
||||
$(self).text('Opting out...')
|
||||
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
method: 'POST',
|
||||
data: {
|
||||
action: 'analyst_opt_out_' + pluginId,
|
||||
nonce: analyst_opt_localize.nonce
|
||||
},
|
||||
success: function (data) {
|
||||
$(self).text('Opt out')
|
||||
|
||||
if (data && !data.success) {
|
||||
$('#analyst-opt-out-modal').hide()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
$error.hide()
|
||||
|
||||
$('#analyst-opt-out-modal').hide()
|
||||
|
||||
isOptingOut = false
|
||||
|
||||
var optInAction = $('<a />').attr({
|
||||
class: 'analyst-action-opt analyst-opt-in',
|
||||
'analyst-plugin-id': pluginId,
|
||||
'analyst-plugin-signed': '1'
|
||||
})
|
||||
.text('Opt In')
|
||||
$('.analyst-opt-out[analyst-plugin-id="'+ pluginId +'"').replaceWith(optInAction)
|
||||
|
||||
$('[analyst-plugin-id="' + pluginId + '"').attr('analyst-plugin-opted-in', 0)
|
||||
|
||||
$mask.hide()
|
||||
},
|
||||
error: function () {
|
||||
$('#analyst-opt-out-error').show()
|
||||
|
||||
$(self).text('Opt out')
|
||||
}
|
||||
}).done(function () {
|
||||
$mask.hide()
|
||||
|
||||
isOptingOut = false
|
||||
})
|
||||
})
|
||||
})(jQuery)
|
||||
</script>
|
||||
Reference in New Issue
Block a user