Ei kuvausta

notice.php 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. $current = time();
  3. if (mktime(0, 0, 0, 11, 23, 2021) <= $current && $current < mktime(0, 0, 0, 12, 1, 2021)) {
  4. if (get_option('nsl_bf_2021') != '1') {
  5. add_action('admin_notices', function () {
  6. ?>
  7. <div class="notice notice-info is-dismissible" data-nsldismissable="nsl_bf_2021" style="display:grid;grid-template-columns: 100px auto;padding-top: 25px; padding-bottom: 22px;">
  8. <img alt="Nextend Social Login" src="<?php echo plugins_url('images/notice/nslnotice.png', NSL_ADMIN_PATH) ?>" width="74" height="74" style="grid-row: 1 / 4; align-self: center;justify-self: center">
  9. <h3 style="margin:0;">Nextend Social Login - Black Friday Deal</h3>
  10. <p style="margin:0 0 2px;">Don't miss out on our biggest sale of the year! Get your <b>Pro Addon</b>
  11. with <b>40% OFF</b> to access <b>WooCommerce support</b>, Apple provider and much more!
  12. Limited time offer expires on November 30.</p>
  13. <p style="margin:0;">
  14. <a class="button button-primary" href="https://nextendweb.com/social-login/?coupon=SAVE4021&utm_source=wpfree&utm_medium=wp&utm_campaign=bf21#pricing" target="_blank">
  15. Buy Now</a>
  16. <a class="button button-dismiss" href="#">Dismiss</a>
  17. </p>
  18. </div>
  19. <?php
  20. });
  21. add_action('admin_footer', function () {
  22. ?>
  23. <script>
  24. (function () {
  25. function ready(fn) {
  26. if (document.readyState === "complete" || document.readyState === "interactive") {
  27. fn();
  28. } else {
  29. document.addEventListener("DOMContentLoaded", fn);
  30. }
  31. }
  32. function serialize(obj) {
  33. return Object.keys(obj).reduce(function (a, k) {
  34. a.push(k + '=' + encodeURIComponent(obj[k]));
  35. return a;
  36. }, []).join('&');
  37. }
  38. ready(function () {
  39. setTimeout(function () {
  40. const buttons = document.querySelectorAll("div[data-nsldismissable] .notice-dismiss, div[data-nsldismissable] .button-dismiss");
  41. for (let i = 0; i < buttons.length; i++) {
  42. buttons[i].addEventListener('click', function (e) {
  43. e.preventDefault();
  44. const http = new XMLHttpRequest();
  45. http.open('POST', ajaxurl, true);
  46. http.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
  47. http.send(serialize({
  48. 'action': 'nsl_dismiss_admin_notice',
  49. 'nonce': <?php echo json_encode(wp_create_nonce('nsl-dismissible-notice')); ?>
  50. }));
  51. e.target.closest('.is-dismissible').remove();
  52. });
  53. }
  54. }, 1000);
  55. });
  56. })();
  57. </script>
  58. <?php
  59. });
  60. add_action('wp_ajax_nsl_dismiss_admin_notice', function () {
  61. check_ajax_referer('nsl-dismissible-notice', 'nonce');
  62. update_option('nsl_bf_2021', '1');
  63. wp_die();
  64. });
  65. }
  66. }