optout.php
111 lines
| 1 | <div id="analyst-opt-out-modal" class="analyst-modal" style="display: none"> |
| 2 | <div class="analyst-modal-content" style="width: 600px"> |
| 3 | <div class="analyst-disable-modal-mask" id="analyst-disable-opt-out-modal-mask" style="display: none"></div> |
| 4 | <div style="display: flex"> |
| 5 | <div class="analyst-install-image-block" style="width: 120px"> |
| 6 | <img src="<?php echo $shieldImage; ?>"/> |
| 7 | </div> |
| 8 | <div class="analyst-install-description-block"> |
| 9 | <strong class="analyst-modal-header">By opting out, we cannot alert you anymore in case of important security updates.</strong> |
| 10 | <p class="analyst-install-description-text"> |
| 11 | In addition, we won’t get pointers how to further improve the plugin based on your integration with our plugin. |
| 12 | </p> |
| 13 | </div> |
| 14 | </div> |
| 15 | <div class="analyst-modal-def-top-padding"> |
| 16 | <button class="analyst-btn-success opt-out-modal-close">Ok, don't opt out</button> |
| 17 | </div> |
| 18 | <div class="analyst-modal-def-top-padding" style="text-align: center;"> |
| 19 | <button class="analyst-btn-secondary-ghost" id="opt-out-action">Opt out</button> |
| 20 | </div> |
| 21 | <div id="analyst-opt-out-error" class="analyst-modal-def-top-padding" style="display: none;"> |
| 22 | <span style="color: #dc3232; font-size: 16px">Service unavailable. Please try again later</span> |
| 23 | </div> |
| 24 | </div> |
| 25 | </div> |
| 26 | </div> |
| 27 | |
| 28 | <script type="text/javascript"> |
| 29 | |
| 30 | (function ($) { |
| 31 | var isOptingOut = false |
| 32 | |
| 33 | $('#analyst-opt-out-modal').appendTo($('body')) |
| 34 | |
| 35 | $(document).on('click', '.analyst-opt-out', function() { |
| 36 | var pluginId = $(this).attr('analyst-plugin-id') |
| 37 | |
| 38 | $('#analyst-opt-out-modal') |
| 39 | .attr({'analyst-plugin-id': pluginId}) |
| 40 | .show() |
| 41 | }) |
| 42 | |
| 43 | $('.opt-out-modal-close').click(function () { |
| 44 | $('#analyst-opt-out-modal').hide() |
| 45 | }) |
| 46 | |
| 47 | $('#opt-out-action').click(function () { |
| 48 | if (isOptingOut) return |
| 49 | |
| 50 | var $mask = $('#analyst-disable-opt-out-modal-mask') |
| 51 | var $error = $('#analyst-opt-out-error') |
| 52 | |
| 53 | var pluginId = $('#analyst-opt-out-modal').attr('analyst-plugin-id') |
| 54 | |
| 55 | $mask.show() |
| 56 | $error.hide() |
| 57 | |
| 58 | var self = this |
| 59 | |
| 60 | isOptingOut = true |
| 61 | |
| 62 | $(self).text('Opting out...') |
| 63 | |
| 64 | $.ajax({ |
| 65 | url: ajaxurl, |
| 66 | method: 'POST', |
| 67 | data: { |
| 68 | action: 'analyst_opt_out_' + pluginId, |
| 69 | nonce: analyst_opt_localize.nonce |
| 70 | }, |
| 71 | success: function (data) { |
| 72 | $(self).text('Opt out') |
| 73 | |
| 74 | if (data && !data.success) { |
| 75 | $('#analyst-opt-out-modal').hide() |
| 76 | |
| 77 | return |
| 78 | } |
| 79 | |
| 80 | $error.hide() |
| 81 | |
| 82 | $('#analyst-opt-out-modal').hide() |
| 83 | |
| 84 | isOptingOut = false |
| 85 | |
| 86 | var optInAction = $('<a />').attr({ |
| 87 | class: 'analyst-action-opt analyst-opt-in', |
| 88 | 'analyst-plugin-id': pluginId, |
| 89 | 'analyst-plugin-signed': '1' |
| 90 | }) |
| 91 | .text('Opt In') |
| 92 | $('.analyst-opt-out[analyst-plugin-id="'+ pluginId +'"').replaceWith(optInAction) |
| 93 | |
| 94 | $('[analyst-plugin-id="' + pluginId + '"').attr('analyst-plugin-opted-in', 0) |
| 95 | |
| 96 | $mask.hide() |
| 97 | }, |
| 98 | error: function () { |
| 99 | $('#analyst-opt-out-error').show() |
| 100 | |
| 101 | $(self).text('Opt out') |
| 102 | } |
| 103 | }).done(function () { |
| 104 | $mask.hide() |
| 105 | |
| 106 | isOptingOut = false |
| 107 | }) |
| 108 | }) |
| 109 | })(jQuery) |
| 110 | </script> |
| 111 |