/* Tam Rank Admin Bar Notification dismiss (moved out of an inline <script> for wp.org compliance) */
( function () {
	function tamRankDismiss404Alerts() {
		var cfg = window.tamRankAdminBar || {};
		jQuery.ajax( {
			url: cfg.ajaxUrl,
			type: 'POST',
			data: {
				action: 'tam_rank_mark_404_seen',
				nonce: cfg.nonce
			},
			success: function ( response ) {
				if ( response.success ) {
					// Verwijder de admin bar node visueel
					jQuery( '#wp-admin-bar-tam-rank-404-alert' ).fadeOut( 300, function () {
						jQuery( this ).remove();
					} );
				}
			}
		} );
	}

	// Behoud de globale functie voor backward compatibility.
	window.tamRankDismiss404Alerts = tamRankDismiss404Alerts;

	// Event-delegatie i.p.v. een inline onclick-attribuut (wp.org compliance).
	document.addEventListener( 'click', function ( e ) {
		if ( e.target.closest( '#wp-admin-bar-tam-rank-404-dismiss' ) ) {
			e.preventDefault();
			tamRankDismiss404Alerts();
		}
	} );
}() );
