( function( $ ){ // Attach a click event handler to the dismiss button within elements with the specified class $( document ).on( 'click', '.notice-get-started-class .notice-dismiss', function () { // Retrieve the type of the dismissed notice from the "data-notice" attribute var type = $( this ).closest( '.notice-get-started-class' ).data( 'notice' ); // Prepare and send an AJAX request to notify the server about the dismissed notice $.ajax( ajaxurl, { type: 'POST', // Specify the server-side action for handling the dismissed notice data: { action: 'basketball_club_dismissed_notice', // Include the type of the dismissed notice in the data payload type: type, } } ); } ); }( jQuery ) ) // WordClever – AI Content Writer plugin activation document.addEventListener('DOMContentLoaded', function () { const basketball_club_button = document.getElementById('install-activate-button'); if (!basketball_club_button) return; basketball_club_button.addEventListener('click', function (e) { e.preventDefault(); const basketball_club_redirectUrl = basketball_club_button.getAttribute('data-redirect'); // Step 1: Check if plugin is already active const basketball_club_checkData = new FormData(); basketball_club_checkData.append('action', 'check_wordclever_activation'); fetch(installWordcleverData.ajaxurl, { method: 'POST', body: basketball_club_checkData, }) .then(res => res.json()) .then(res => { if (res.success && res.data.active) { // Plugin is already active → just redirect window.location.href = basketball_club_redirectUrl; } else { // Not active → proceed with install + activate basketball_club_button.textContent = 'Installing & Activating...'; const basketball_club_installData = new FormData(); basketball_club_installData.append('action', 'install_and_activate_wordclever_plugin'); basketball_club_installData.append('_ajax_nonce', installWordcleverData.nonce); fetch(installWordcleverData.ajaxurl, { method: 'POST', body: basketball_club_installData, }) .then(res => res.json()) .then(res => { if (res.success) { window.location.href = basketball_club_redirectUrl; } else { alert('Activation error: ' + (res.data?.message || 'Unknown error')); basketball_club_button.textContent = 'Try Again'; } }) .catch(error => { alert('Request failed: ' + error.message); basketball_club_button.textContent = 'Try Again'; }); } }) .catch(error => { alert('Check request failed: ' + error.message); }); }); });