global-scripts.js
41 lines
| 1 | document.addEventListener('DOMContentLoaded', function() { |
| 2 | |
| 3 | const pluginSplitClose = document.getElementById('plugin-split-close'); |
| 4 | |
| 5 | if(pluginSplitClose) { |
| 6 | pluginSplitClose.addEventListener('click', function () { |
| 7 | let nonceElement = document.getElementById('hts_close_plugin_split_nonce'); |
| 8 | |
| 9 | if (!nonceElement) { |
| 10 | console.error('Nonce element not found.'); |
| 11 | return; |
| 12 | } |
| 13 | |
| 14 | let nonce = nonceElement.value; |
| 15 | |
| 16 | fetch(ajaxurl, { |
| 17 | method: 'POST', |
| 18 | headers: { |
| 19 | 'Content-Type': 'application/x-www-form-urlencoded', |
| 20 | }, |
| 21 | body: new URLSearchParams({ |
| 22 | 'action': 'hostinger_dismiss_plugin_split_notice', |
| 23 | 'nonce': nonce |
| 24 | }), |
| 25 | }) |
| 26 | .then(response => { |
| 27 | if (!response.ok) { |
| 28 | throw new Error('Network response was not ok ' + response.statusText); |
| 29 | } |
| 30 | return response.json(); |
| 31 | }) |
| 32 | .then(data => { |
| 33 | document.getElementById('hostinger-plugin-split-notice').style.display = 'none'; |
| 34 | }) |
| 35 | .catch(error => { |
| 36 | console.error('Error:', error); |
| 37 | }); |
| 38 | }); |
| 39 | } |
| 40 | }); |
| 41 |