Reply To: Remove notification count if zero
Hi there,
I’m not sure where you are getting your classes from, I wrote this which works on my system:
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';
}
}
notificationsCounter.addEventListener('change', counterChange);
counterChange();
There’s plugins that allow you to get dynamic notification updates, so just in case you ever want to add that feature in future I made it so that it can dynamically change.