Simple AJAX notification when the new post is added to the database

I would, on admin init hook check latest post’s ID against a saved latest post’s ID in options table and if not that latest one, add a class has-new to the dashboard entry (#adminmenu .menu-icon-dashboard), so you can create a dot on that element with ::after.

Then when user clicks the posts page (check with get_current_screen()) save that latest ID in the options table, so next check would thus not add the has-new class.

Remember to check only for post types that you want to be notified about, and you might want to exclude non published posts in that check.

UPDATE

My answer is not an ajax solution as you asked, so this will not suddenly update the admin panel when it’s idle. For that to work, one would have to simply do that check on interval, so the check would be an ajax function and the interval in some admin.js

error code: 523