Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Remove notification count if zero

@venutius

Moderator

One aspect I forgot was if the user is not logged in, ths would fix that:

const notificationsCounter = document.getElementById('ab-pending-notifications');
const notificationsIndicator = document.getElementById('wp-admin-bar-bp-notifications');

function counterChange() {
	if (notificationsCounter.innerText == '0') {
		notificationsIndicator.style.display = 'none';
	} else {
		notificationsIndicator.style.display = 'block';
	}
}

if (notificationCounter){
    notificationsCounter.addEventListener('change', counterChange);
}
counterChange();
Skip to toolbar