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