wp-content-copy-protector
Last commit date
css
1 day ago
images
1 day ago
js
1 day ago
languages
1 day ago
admin-core.php
1 day ago
deactivation-survey.php
1 day ago
notifications.php
1 day ago
preventer-index.php
1 day ago
readme.txt
1 day ago
right-click-protection.jpg
1 day ago
the_globals.php
1 day ago
watermark-adv.jpg
1 day ago
watermarking-adv-examples.png
1 day ago
deactivation-survey.php
320 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Deactivation feedback survey popup. |
| 5 | * |
| 6 | * Shows a modal on the Plugins screen when the user clicks "Deactivate" on this |
| 7 | * plugin, inviting them to fill in the survey form hosted on wp-buy.com before |
| 8 | * the deactivation goes through. |
| 9 | * |
| 10 | * @package wp-content-copy-protector |
| 11 | * @since 3.7.3 |
| 12 | */ |
| 13 | |
| 14 | if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 15 | |
| 16 | if (! class_exists('wccp_free_Deactivation_Survey')) : |
| 17 | |
| 18 | class wccp_free_Deactivation_Survey |
| 19 | { |
| 20 | |
| 21 | /** |
| 22 | * Where the feedback form lives. |
| 23 | */ |
| 24 | const SURVEY_URL = 'https://www.wp-buy.com/survey/wp-content-copy-protection'; |
| 25 | |
| 26 | /** |
| 27 | * Plugin basename, ie. wp-content-copy-protector/preventer-index.php |
| 28 | * |
| 29 | * @var string |
| 30 | */ |
| 31 | private $plugin_basename = ''; |
| 32 | |
| 33 | public function __construct($plugin_file) |
| 34 | { |
| 35 | |
| 36 | $this->plugin_basename = plugin_basename($plugin_file); |
| 37 | |
| 38 | add_action('admin_footer', array($this, 'wccp_free_survey_modal')); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Only the plugins list (single site + network) gets the modal. |
| 43 | */ |
| 44 | private function wccp_free_is_plugins_screen() |
| 45 | { |
| 46 | |
| 47 | if (! function_exists('get_current_screen')) return false; |
| 48 | |
| 49 | $screen = get_current_screen(); |
| 50 | |
| 51 | if (! $screen) return false; |
| 52 | |
| 53 | return in_array($screen->id, array('plugins', 'plugins-network'), true); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Print the modal markup, styles and the script that hijacks the |
| 58 | * "Deactivate" link for this plugin only. |
| 59 | */ |
| 60 | public function wccp_free_survey_modal() |
| 61 | { |
| 62 | |
| 63 | if (! current_user_can('activate_plugins')) return; |
| 64 | |
| 65 | if (! $this->wccp_free_is_plugins_screen()) return; |
| 66 | |
| 67 | $icon_path = plugins_url('/images/icon-128x128.png', __FILE__); |
| 68 | |
| 69 | $survey_url = self::SURVEY_URL; |
| 70 | |
| 71 | if (defined('WCCP_FREE_VERSION')) { |
| 72 | $survey_url = add_query_arg('ver', WCCP_FREE_VERSION, $survey_url); |
| 73 | } |
| 74 | ?> |
| 75 | <style> |
| 76 | #wccp_free_survey_overlay { |
| 77 | position: fixed; |
| 78 | top: 0; |
| 79 | left: 0; |
| 80 | width: 100%; |
| 81 | height: 100%; |
| 82 | background: rgba(0, 0, 0, .65); |
| 83 | z-index: 100000; |
| 84 | display: none; |
| 85 | } |
| 86 | |
| 87 | #wccp_free_survey_overlay.wccp_free_open { |
| 88 | display: flex; |
| 89 | align-items: center; |
| 90 | justify-content: center; |
| 91 | } |
| 92 | |
| 93 | #wccp_free_survey_modal { |
| 94 | position: relative; |
| 95 | width: 100%; |
| 96 | max-width: 520px; |
| 97 | margin: 20px; |
| 98 | background: #fff; |
| 99 | border-radius: 6px; |
| 100 | box-shadow: 0 5px 30px rgba(0, 0, 0, .35); |
| 101 | box-sizing: border-box; |
| 102 | max-height: 90vh; |
| 103 | overflow-y: auto; |
| 104 | } |
| 105 | |
| 106 | #wccp_free_survey_modal .wccp_free_survey_head { |
| 107 | display: flex; |
| 108 | align-items: center; |
| 109 | gap: 14px; |
| 110 | padding: 20px 24px; |
| 111 | border-bottom: 1px solid #e2e4e7; |
| 112 | background: #f6f7f7; |
| 113 | border-radius: 6px 6px 0 0; |
| 114 | } |
| 115 | |
| 116 | #wccp_free_survey_modal .wccp_free_survey_head img { |
| 117 | width: 48px; |
| 118 | height: 48px; |
| 119 | flex: 0 0 48px; |
| 120 | } |
| 121 | |
| 122 | #wccp_free_survey_modal .wccp_free_survey_head h2 { |
| 123 | margin: 0; |
| 124 | font-size: 18px; |
| 125 | line-height: 1.4; |
| 126 | } |
| 127 | |
| 128 | #wccp_free_survey_modal:focus { |
| 129 | outline: none; |
| 130 | } |
| 131 | |
| 132 | #wccp_free_survey_modal .wccp_free_survey_body { |
| 133 | padding: 20px 24px; |
| 134 | } |
| 135 | |
| 136 | #wccp_free_survey_modal .wccp_free_survey_body p { |
| 137 | margin: 0 0 14px; |
| 138 | font-size: 14px; |
| 139 | line-height: 1.6; |
| 140 | } |
| 141 | |
| 142 | #wccp_free_survey_modal .wccp_free_survey_gift { |
| 143 | margin: 0 0 4px !important; |
| 144 | padding: 12px 14px; |
| 145 | background: #f0f0f1; |
| 146 | border-left: 4px solid #8c8f94; |
| 147 | color: #3c434a; |
| 148 | } |
| 149 | |
| 150 | #wccp_free_survey_modal .wccp_free_survey_reward { |
| 151 | color: #b34700; |
| 152 | font-weight: 700; |
| 153 | background: #fff1e0; |
| 154 | padding: 1px 5px; |
| 155 | border-radius: 3px; |
| 156 | white-space: normal; |
| 157 | } |
| 158 | |
| 159 | #wccp_free_survey_modal .wccp_free_survey_footer { |
| 160 | display: flex; |
| 161 | align-items: center; |
| 162 | flex-wrap: wrap; |
| 163 | gap: 12px; |
| 164 | padding: 16px 24px 20px; |
| 165 | } |
| 166 | |
| 167 | #wccp_free_survey_modal .wccp_free_survey_skip { |
| 168 | margin-left: auto; |
| 169 | color: #646970; |
| 170 | text-decoration: none; |
| 171 | font-size: 13px; |
| 172 | } |
| 173 | |
| 174 | #wccp_free_survey_modal .wccp_free_survey_skip:hover, |
| 175 | #wccp_free_survey_modal .wccp_free_survey_skip:focus { |
| 176 | color: #3c434a; |
| 177 | text-decoration: underline; |
| 178 | } |
| 179 | |
| 180 | #wccp_free_survey_close { |
| 181 | position: absolute; |
| 182 | top: 10px; |
| 183 | right: 10px; |
| 184 | border: 0; |
| 185 | background: none; |
| 186 | cursor: pointer; |
| 187 | padding: 4px; |
| 188 | color: #787c82; |
| 189 | line-height: 1; |
| 190 | } |
| 191 | |
| 192 | #wccp_free_survey_close:hover, |
| 193 | #wccp_free_survey_close:focus { |
| 194 | color: #3c434a; |
| 195 | } |
| 196 | |
| 197 | @media screen and (max-width: 600px) { |
| 198 | #wccp_free_survey_modal .wccp_free_survey_footer { |
| 199 | flex-direction: column; |
| 200 | align-items: stretch; |
| 201 | } |
| 202 | |
| 203 | #wccp_free_survey_modal .wccp_free_survey_skip { |
| 204 | margin-left: 0; |
| 205 | text-align: center; |
| 206 | } |
| 207 | } |
| 208 | </style> |
| 209 | |
| 210 | <div id="wccp_free_survey_overlay" aria-hidden="true"> |
| 211 | <div id="wccp_free_survey_modal" role="dialog" aria-modal="true" aria-labelledby="wccp_free_survey_title" tabindex="-1"> |
| 212 | |
| 213 | <button type="button" id="wccp_free_survey_close"> |
| 214 | <span class="dashicons dashicons-no-alt"></span> |
| 215 | <span class="screen-reader-text"><?php esc_html_e('Close', 'wp-content-copy-protector'); ?></span> |
| 216 | </button> |
| 217 | |
| 218 | <div class="wccp_free_survey_head"> |
| 219 | <img src="<?php echo esc_url($icon_path); ?>" alt=""> |
| 220 | <h2 id="wccp_free_survey_title"><?php esc_html_e('Before you go, may we ask why?', 'wp-content-copy-protector'); ?></h2> |
| 221 | </div> |
| 222 | |
| 223 | <div class="wccp_free_survey_body"> |
| 224 | <p><?php esc_html_e('We are sorry to see you deactivate WP Content Copy Protection. Telling us what went wrong takes less than a minute, and it is the fastest way for us to fix it, for you and for everyone else.', 'wp-content-copy-protector'); ?></p> |
| 225 | <p class="wccp_free_survey_gift"> |
| 226 | <strong><?php esc_html_e('A thank you from us:', 'wp-content-copy-protector'); ?></strong> |
| 227 | <?php |
| 228 | printf( |
| 229 | /* translators: %s: the highlighted "FREE one month subscription to our PRO version" reward. */ |
| 230 | esc_html__('completing this survey accurately qualifies you to receive a %s, on the house!', 'wp-content-copy-protector'), |
| 231 | '<span class="wccp_free_survey_reward">' . esc_html__('FREE one month subscription to our PRO version', 'wp-content-copy-protector') . '</span>' |
| 232 | ); |
| 233 | ?> |
| 234 | </p> |
| 235 | </div> |
| 236 | |
| 237 | <div class="wccp_free_survey_footer"> |
| 238 | <a href="<?php echo esc_url($survey_url); ?>" class="button button-primary" id="wccp_free_survey_go" target="_blank" rel="noopener noreferrer"> |
| 239 | <?php esc_html_e('Take the survey & claim my free month', 'wp-content-copy-protector'); ?> |
| 240 | </a> |
| 241 | <a href="#" class="wccp_free_survey_skip" id="wccp_free_survey_skip"> |
| 242 | <?php esc_html_e('Skip & deactivate', 'wp-content-copy-protector'); ?> |
| 243 | </a> |
| 244 | </div> |
| 245 | |
| 246 | </div> |
| 247 | </div> |
| 248 | |
| 249 | <script> |
| 250 | jQuery(function($) { |
| 251 | |
| 252 | var pluginBasename = <?php echo wp_json_encode($this->plugin_basename); ?>; |
| 253 | var overlay = $('#wccp_free_survey_overlay'); |
| 254 | var deactivateUrl = ''; |
| 255 | |
| 256 | // The "Deactivate" row action of this plugin only. |
| 257 | var pluginRow = $('#the-list tr[data-plugin="' + pluginBasename + '"]'); |
| 258 | var deactivateLink = pluginRow.find('span.deactivate a'); |
| 259 | |
| 260 | if (!deactivateLink.length) { |
| 261 | deactivateLink = pluginRow.find('a[href*="action=deactivate"]'); |
| 262 | } |
| 263 | |
| 264 | if (!deactivateLink.length) { |
| 265 | return; // Plugin row not on screen (filtered view), nothing to hook. |
| 266 | } |
| 267 | |
| 268 | function openModal() { |
| 269 | overlay.addClass('wccp_free_open').attr('aria-hidden', 'false'); |
| 270 | $('#wccp_free_survey_modal').trigger('focus'); |
| 271 | } |
| 272 | |
| 273 | function closeModal() { |
| 274 | overlay.removeClass('wccp_free_open').attr('aria-hidden', 'true'); |
| 275 | } |
| 276 | |
| 277 | deactivateLink.on('click', function(e) { |
| 278 | e.preventDefault(); |
| 279 | deactivateUrl = $(this).attr('href'); |
| 280 | openModal(); |
| 281 | }); |
| 282 | |
| 283 | // Survey opens in a new tab, then we carry on with the deactivation. |
| 284 | $('#wccp_free_survey_go').on('click', function() { |
| 285 | closeModal(); |
| 286 | if (deactivateUrl) { |
| 287 | window.setTimeout(function() { |
| 288 | window.location.href = deactivateUrl; |
| 289 | }, 500); |
| 290 | } |
| 291 | }); |
| 292 | |
| 293 | $('#wccp_free_survey_skip').on('click', function(e) { |
| 294 | e.preventDefault(); |
| 295 | if (deactivateUrl) { |
| 296 | window.location.href = deactivateUrl; |
| 297 | } |
| 298 | }); |
| 299 | |
| 300 | // Closing the modal cancels the deactivation, the plugin stays active. |
| 301 | $('#wccp_free_survey_close').on('click', closeModal); |
| 302 | |
| 303 | overlay.on('click', function(e) { |
| 304 | if (e.target === this) closeModal(); |
| 305 | }); |
| 306 | |
| 307 | $(document).on('keyup', function(e) { |
| 308 | if (e.key === 'Escape' && overlay.hasClass('wccp_free_open')) closeModal(); |
| 309 | }); |
| 310 | |
| 311 | }); |
| 312 | </script> |
| 313 | <?php |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | endif; |
| 318 | |
| 319 | new wccp_free_Deactivation_Survey(WCCP_FREE_PLUGIN_FILE); |
| 320 |