| 1 |
/** |
| 2 |
* Admin notice dismissal handler. |
| 3 |
* |
| 4 |
* Reads configs pushed into window.adminNoticesConfigs by each plugin instance |
| 5 |
* via wp_add_inline_script. Each config object contains: |
| 6 |
* - prefix {string} Plugin prefix (matches data-notice-prefix attribute). |
| 7 |
* - action {string} AJAX action name. |
| 8 |
* - nonce {string} Nonce for the AJAX request. |
| 9 |
*/ |
| 10 |
jQuery(document).ready(function ($) { |
| 11 |
var configs = window.adminNoticesConfigs || []; |
| 12 |
|
| 13 |
configs.forEach(function (config) { |
| 14 |
$('.notice[data-notice-prefix="' + config.prefix + '"]').on('click', '.notice-dismiss', function () { |
| 15 |
var $notice = $(this).closest('.notice'); |
| 16 |
|
| 17 |
$.post(ajaxurl, { |
| 18 |
action: config.action, |
| 19 |
notice_id: $notice.data('notice-id'), |
| 20 |
dismiss_time: $notice.data('dismiss-time'), |
| 21 |
nonce: config.nonce |
| 22 |
}); |
| 23 |
}); |
| 24 |
}); |
| 25 |
}); |
| 26 |
|