| 1 |
<?php |
| 2 |
namespace EmailKit\Promotional; |
| 3 |
defined('ABSPATH') || exit; |
| 4 |
class ProConsent{ |
| 5 |
public function get_consent_form(){ |
| 6 |
// Check if EmailKit Pro is active (replace with your actual check) |
| 7 |
$is_pro_active = is_plugin_active('emailkit-pro/emailkit-pro.php'); |
| 8 |
$buy_pro_url = 'https://wpmet.com/plugin/emailkit/pricing/'; |
| 9 |
$show_pro_badge = !$is_pro_active; |
| 10 |
?> |
| 11 |
<style> |
| 12 |
.emailkit-user-consent-for-banner{ |
| 13 |
margin: 0 0 15px 0!important; |
| 14 |
width: 842px; |
| 15 |
max-width: 1350px; |
| 16 |
} |
| 17 |
.emailkit-success-notice { |
| 18 |
position: fixed; |
| 19 |
top: 50px; |
| 20 |
right: 20px; |
| 21 |
background-color: #14c87c; |
| 22 |
color: white; |
| 23 |
padding: 10px; |
| 24 |
border-radius: 5px; |
| 25 |
display: none; |
| 26 |
} |
| 27 |
.emailkit-copy-paste-section { |
| 28 |
margin-top: 20px; |
| 29 |
padding: 15px 20px; |
| 30 |
background: #fff; |
| 31 |
border: 1px solid #e4e7ef; |
| 32 |
border-radius: 10px; |
| 33 |
max-width: 350px; |
| 34 |
min-width: 300px; |
| 35 |
height: auto; |
| 36 |
min-height: 56px; |
| 37 |
position: relative; |
| 38 |
box-shadow: 0 2px 8px 0 rgba(44,62,80,.04); |
| 39 |
display: flex; |
| 40 |
align-items: center; |
| 41 |
} |
| 42 |
.emailkit-copy-paste-section span { |
| 43 |
font-size: 16px; |
| 44 |
font-weight: 500; |
| 45 |
} |
| 46 |
.emailkit-pro-badge { |
| 47 |
position: absolute; |
| 48 |
top: -10px; |
| 49 |
right: 12px; |
| 50 |
background: #ff5e8a; |
| 51 |
color: #fff; |
| 52 |
font-size: 12px; |
| 53 |
font-weight: 700; |
| 54 |
padding: 2px 14px 2px 14px; |
| 55 |
border-radius: 16px; |
| 56 |
box-shadow: 0 2px 8px 0 rgba(44,62,80,.08); |
| 57 |
z-index: 10; |
| 58 |
letter-spacing: 1px; |
| 59 |
} |
| 60 |
/* Toggle Switch Styles */ |
| 61 |
.emailkit-switch { |
| 62 |
position: relative; |
| 63 |
display: inline-block; |
| 64 |
width: 46px; |
| 65 |
height: 24px; |
| 66 |
vertical-align: middle; |
| 67 |
} |
| 68 |
.emailkit-switch input { |
| 69 |
opacity: 0; |
| 70 |
width: 0; |
| 71 |
height: 0; |
| 72 |
} |
| 73 |
.emailkit-slider { |
| 74 |
position: absolute; |
| 75 |
cursor: pointer; |
| 76 |
top: 0; left: 0; right: 0; bottom: 0; |
| 77 |
background-color: #ccc; |
| 78 |
transition: .4s; |
| 79 |
border-radius: 24px; |
| 80 |
} |
| 81 |
.emailkit-slider:before { |
| 82 |
position: absolute; |
| 83 |
content: ""; |
| 84 |
height: 18px; |
| 85 |
width: 18px; |
| 86 |
left: 3px; |
| 87 |
bottom: 3px; |
| 88 |
background-color: white; |
| 89 |
transition: .4s; |
| 90 |
border-radius: 50%; |
| 91 |
} |
| 92 |
.emailkit-switch input:checked + .emailkit-slider { |
| 93 |
background-color: #14c87c; |
| 94 |
} |
| 95 |
.emailkit-switch input:checked + .emailkit-slider:before { |
| 96 |
transform: translateX(22px); |
| 97 |
} |
| 98 |
.emailkit-switch-label { |
| 99 |
margin-left: 12px; |
| 100 |
font-weight: 500; |
| 101 |
vertical-align: middle; |
| 102 |
} |
| 103 |
.emailkit-switch-modern { |
| 104 |
position: relative; |
| 105 |
display: inline-block; |
| 106 |
width: 60px; |
| 107 |
height: 28px; |
| 108 |
margin: 0 0 0 auto; |
| 109 |
vertical-align: middle; |
| 110 |
flex-shrink: 0; |
| 111 |
} |
| 112 |
.emailkit-switch-modern input { |
| 113 |
opacity: 0; |
| 114 |
width: 0; |
| 115 |
height: 0; |
| 116 |
} |
| 117 |
.emailkit-switch-modern.disabled, |
| 118 |
.emailkit-switch-modern input:disabled + .emailkit-slider-modern { |
| 119 |
cursor: not-allowed; |
| 120 |
} |
| 121 |
.emailkit-copy-paste-section.disabled { |
| 122 |
cursor: pointer; |
| 123 |
} |
| 124 |
.emailkit-copy-paste-section.disabled .emailkit-switch-modern { |
| 125 |
pointer-events: none; |
| 126 |
} |
| 127 |
.emailkit-slider-modern { |
| 128 |
position: absolute; |
| 129 |
cursor: pointer; |
| 130 |
top: 0; left: 0; right: 0; bottom: 0; |
| 131 |
background-color: #f3f4f6; |
| 132 |
transition: background-color .4s; |
| 133 |
border-radius: 999px; |
| 134 |
display: flex; |
| 135 |
align-items: center; |
| 136 |
justify-content: center; |
| 137 |
border: 1.5px solid #e4e7ef; |
| 138 |
} |
| 139 |
.emailkit-switch-modern input:checked + .emailkit-slider-modern { |
| 140 |
background-color: #2563eb; |
| 141 |
border: 1.5px solid #2563eb; |
| 142 |
} |
| 143 |
.emailkit-slider-modern:before { |
| 144 |
position: absolute; |
| 145 |
content: ""; |
| 146 |
height: 20px; |
| 147 |
width: 20px; |
| 148 |
left: 3px; |
| 149 |
top: 3px; |
| 150 |
background-color: #fff; |
| 151 |
border-radius: 50%; |
| 152 |
transition: transform .4s; |
| 153 |
z-index: 2; |
| 154 |
box-shadow: 0 2px 8px 0 rgba(44,62,80,.08); |
| 155 |
} |
| 156 |
.emailkit-switch-modern input:checked + .emailkit-slider-modern:before { |
| 157 |
transform: translateX(30px); |
| 158 |
} |
| 159 |
.emailkit-switch-text { |
| 160 |
position: absolute; |
| 161 |
top: 50%; |
| 162 |
transform: translateY(-50%); |
| 163 |
font-size: 12px !important; |
| 164 |
text-align: center; |
| 165 |
user-select: none; |
| 166 |
transition: color .4s, left .4s, right .4s; |
| 167 |
z-index: 1; |
| 168 |
font-weight: 600; |
| 169 |
letter-spacing: 0.5px; |
| 170 |
width: 22px; |
| 171 |
} |
| 172 |
.emailkit-switch-modern input:checked + .emailkit-slider-modern .emailkit-switch-text { |
| 173 |
left: 8px; |
| 174 |
right: auto; |
| 175 |
color: #fff; |
| 176 |
} |
| 177 |
.emailkit-switch-modern input:not(:checked) + .emailkit-slider-modern .emailkit-switch-text { |
| 178 |
right: 8px; |
| 179 |
left: auto; |
| 180 |
color: #b0b7c3; |
| 181 |
} |
| 182 |
/* Pro Modal Styles */ |
| 183 |
.emailkit-pro-modal { |
| 184 |
display: none; |
| 185 |
position: fixed; |
| 186 |
z-index: 9999; |
| 187 |
left: 0; |
| 188 |
top: 0; |
| 189 |
width: 100%; |
| 190 |
height: 100%; |
| 191 |
background-color: rgba(0,0,0,0.5); |
| 192 |
} |
| 193 |
.emailkit-pro-modal-content { |
| 194 |
background-color: #fefefe; |
| 195 |
margin: 5% auto; |
| 196 |
padding: 40px; |
| 197 |
border-radius: 20px; |
| 198 |
width: 500px; |
| 199 |
max-width: 90%; |
| 200 |
text-align: center; |
| 201 |
position: relative; |
| 202 |
box-shadow: 0 20px 60px rgba(0,0,0,0.15); |
| 203 |
} |
| 204 |
.emailkit-pro-modal-close { |
| 205 |
position: absolute; |
| 206 |
top: 20px; |
| 207 |
right: 25px; |
| 208 |
color: #aaa; |
| 209 |
font-size: 28px; |
| 210 |
font-weight: bold; |
| 211 |
cursor: pointer; |
| 212 |
width: 30px; |
| 213 |
height: 30px; |
| 214 |
display: flex; |
| 215 |
align-items: center; |
| 216 |
justify-content: center; |
| 217 |
} |
| 218 |
.emailkit-pro-modal-close:hover { |
| 219 |
color: #000; |
| 220 |
} |
| 221 |
.emailkit-pro-modal-icon { |
| 222 |
width: 80px; |
| 223 |
height: 80px; |
| 224 |
background: #e8f2ff; |
| 225 |
border-radius: 50%; |
| 226 |
margin: 0 auto 30px; |
| 227 |
display: flex; |
| 228 |
align-items: center; |
| 229 |
justify-content: center; |
| 230 |
font-size: 40px; |
| 231 |
color: #2563eb; |
| 232 |
} |
| 233 |
.emailkit-pro-modal-title { |
| 234 |
font-size: 32px; |
| 235 |
font-weight: 700; |
| 236 |
color: #333; |
| 237 |
margin-bottom: 15px; |
| 238 |
} |
| 239 |
.emailkit-pro-modal-text { |
| 240 |
font-size: 16px; |
| 241 |
color: #666; |
| 242 |
margin-bottom: 30px; |
| 243 |
line-height: 1.5; |
| 244 |
} |
| 245 |
.emailkit-pro-modal-link { |
| 246 |
color: #2563eb; |
| 247 |
text-decoration: underline; |
| 248 |
font-weight: 600; |
| 249 |
} |
| 250 |
.emailkit-disabled-overlay { |
| 251 |
cursor: pointer; |
| 252 |
} |
| 253 |
</style> |
| 254 |
<script> |
| 255 |
jQuery(document).ready(function ($) { |
| 256 |
"use strict"; |
| 257 |
$('#emailkit-admin-switch__emailkit-user-consent-for-banner').on('change', function(){ |
| 258 |
let val = ($(this).prop("checked") ? $(this).val() : 'no'); |
| 259 |
let data = { |
| 260 |
'settings' : { |
| 261 |
'emailkit_user_consent_for_banner' : val, |
| 262 |
}, |
| 263 |
'nonce': "<?php echo esc_html(wp_create_nonce( 'ajax-nonce' )); ?>" |
| 264 |
}; |
| 265 |
$.post( ajaxurl + '?action=emailkit_admin_action', data, function( data ) { |
| 266 |
$('#success-notice').fadeIn().delay(1000).slideUp(); |
| 267 |
}); |
| 268 |
}); |
| 269 |
|
| 270 |
function updateSwitchText() { |
| 271 |
var $switch = $('#emailkit-enable-copy-paste-switch'); |
| 272 |
var $text = $switch.next('.emailkit-slider-modern').find('.emailkit-switch-text'); |
| 273 |
if ($switch.is(':checked')) { |
| 274 |
$text.text('ON'); |
| 275 |
} else { |
| 276 |
$text.text('OFF'); |
| 277 |
} |
| 278 |
} |
| 279 |
|
| 280 |
function updateSwitchState() { |
| 281 |
var $switch = $('#emailkit-enable-copy-paste-switch'); |
| 282 |
var $container = $('.emailkit-copy-paste-section'); |
| 283 |
var isProActive = <?php echo esc_attr($is_pro_active ? 'true' : 'false'); ?>; |
| 284 |
|
| 285 |
if (isProActive) { |
| 286 |
// Enable switch when Pro is active |
| 287 |
$switch.prop('disabled', false); |
| 288 |
$container.removeClass('disabled'); |
| 289 |
$('.emailkit-switch-modern').removeClass('disabled'); |
| 290 |
} else { |
| 291 |
// Disable switch when Pro is not active |
| 292 |
$switch.prop('disabled', true).prop('checked', false); |
| 293 |
$container.addClass('disabled'); |
| 294 |
$('.emailkit-switch-modern').addClass('disabled'); |
| 295 |
} |
| 296 |
updateSwitchText(); |
| 297 |
} |
| 298 |
|
| 299 |
updateSwitchState(); |
| 300 |
|
| 301 |
$('#emailkit-enable-copy-paste-switch').on('change', function(){ |
| 302 |
// Only allow changes if Pro is active |
| 303 |
if (<?php echo esc_attr($is_pro_active ? 'true' : 'false'); ?>) { |
| 304 |
updateSwitchText(); |
| 305 |
let val = $(this).prop('checked') ? 'yes' : 'no'; |
| 306 |
let data = { |
| 307 |
'copy_paste_enabled': val, |
| 308 |
'nonce': "<?php echo esc_html(wp_create_nonce( 'ajax-nonce' )); ?>" |
| 309 |
}; |
| 310 |
$.post(ajaxurl + '?action=emailkit_copy_paste_action', data, function(response) { |
| 311 |
if (response.success) { |
| 312 |
$('#success-notice').fadeIn().delay(1000).slideUp(); |
| 313 |
} else { |
| 314 |
console.error('Failed to save copy-paste setting:', response.data.message); |
| 315 |
} |
| 316 |
}); |
| 317 |
} else { |
| 318 |
// Prevent changes and show modal if Pro is not active |
| 319 |
$(this).prop('checked', false); |
| 320 |
updateSwitchText(); |
| 321 |
$('#emailkit-pro-modal').show(); |
| 322 |
} |
| 323 |
}); |
| 324 |
|
| 325 |
// Pro Modal functionality |
| 326 |
$('.emailkit-copy-paste-section.disabled').on('click', function(e) { |
| 327 |
e.preventDefault(); |
| 328 |
$('#emailkit-pro-modal').show(); |
| 329 |
}); |
| 330 |
|
| 331 |
$('.emailkit-pro-modal-close, .emailkit-pro-modal').on('click', function(e) { |
| 332 |
if (e.target === this) { |
| 333 |
$('#emailkit-pro-modal').hide(); |
| 334 |
} |
| 335 |
}); |
| 336 |
}); // end ready function |
| 337 |
</script> |
| 338 |
|
| 339 |
<div id="success-notice" class="emailkit-success-notice"><?php esc_html_e( 'Success! Your action was completed.', 'emailkit' ); ?></div> |
| 340 |
<div class="emailkit-user-consent-for-banner notice notice-error"> |
| 341 |
<p> |
| 342 |
<input type="checkbox" <?php echo esc_attr( \EmailKit\Promotional\Util::get_settings( 'emailkit_user_consent_for_banner', 'yes' ) == 'yes' ? 'checked' : '' ); ?> value="yes" class="emailkit-admin-control-input" name="emailkit-user-consent-for-banner" id="emailkit-admin-switch__emailkit-user-consent-for-banner"> |
| 343 |
<label for="emailkit-admin-switch__emailkit-user-consent-for-banner"><?php esc_html_e( 'Show update & fix related important messages, essential tutorials and promotional images on WP Dashboard', 'emailkit' ); ?></label> |
| 344 |
</p> |
| 345 |
</div> |
| 346 |
|
| 347 |
<!-- Copy-paste switch only --> |
| 348 |
<div class="emailkit-copy-paste-section<?php echo esc_attr(!$is_pro_active) ? ' disabled' : ''; ?>"> |
| 349 |
<?php if ($show_pro_badge): ?> |
| 350 |
<span class="emailkit-pro-badge"><?php esc_html_e( 'PRO', 'emailkit' ); ?></span> |
| 351 |
<?php endif; ?> |
| 352 |
<span style="flex: 1; margin-right: 16px;"><?php esc_html_e('Enable Copy Paste', 'emailkit'); ?></span> |
| 353 |
<label class="emailkit-switch-modern<?php echo esc_attr(!$is_pro_active) ? ' disabled' : ''; ?>"> |
| 354 |
<input type="checkbox" id="emailkit-enable-copy-paste-switch" value="yes" <?php echo esc_attr(($is_pro_active && \EmailKit\Promotional\Util::get_settings('emailkit_enable_copy_paste', 'no') == 'yes') ? 'checked' : ''); ?> <?php echo esc_attr(!$is_pro_active ? 'disabled' : ''); ?> /> |
| 355 |
<span class="emailkit-slider-modern"> |
| 356 |
<span class="emailkit-switch-text"></span> |
| 357 |
</span> |
| 358 |
</label> |
| 359 |
</div> |
| 360 |
|
| 361 |
<!-- Pro Modal --> |
| 362 |
<?php if (!$is_pro_active): ?> |
| 363 |
<div id="emailkit-pro-modal" class="emailkit-pro-modal"> |
| 364 |
<div class="emailkit-pro-modal-content"> |
| 365 |
<span class="emailkit-pro-modal-close">×</span> |
| 366 |
<div class="emailkit-pro-modal-icon"> |
| 367 |
<i style="font-style: normal; font-weight: bold;">i</i> |
| 368 |
</div> |
| 369 |
<h2 class="emailkit-pro-modal-title"><?php esc_html_e( 'Go Premium', 'emailkit' ); ?></h2> |
| 370 |
<p class="emailkit-pro-modal-text"> |
| 371 |
<?php |
| 372 |
printf( |
| 373 |
/* translators: %s: "pro version" link to the EmailKit pricing page. */ |
| 374 |
esc_html__( 'Purchase our %s to unlock these premium features!', 'emailkit' ), |
| 375 |
'<a href="' . esc_url( $buy_pro_url ) . '" target="_blank" class="emailkit-pro-modal-link">' . esc_html__( 'pro version', 'emailkit' ) . '</a>' |
| 376 |
); |
| 377 |
?> |
| 378 |
</p> |
| 379 |
</div> |
| 380 |
</div> |
| 381 |
<?php endif; ?> |
| 382 |
<?php |
| 383 |
} |
| 384 |
} |