Wordpress: how to make custom notifications in the admin?

How you can implement notifications in the admin?
Like this:
387d736a8ddf4cc8b094a536bee8860f.jpg
July 2nd 19 at 13:28
1 answer
July 2nd 19 at 13:30
Solution
Where you add your menu item title of your item, add this value:
$menu_title .= '<span class="update-count">' . $count . '</span>';

Well, he $count separately consider. I would have made it a separate function with a cache, and simply return from it's value. Then the code will look like:
$menu_title .= '<span class="update-count">' . get_my_count() . '</span>';

where get_my_count() is my function count that must be considered (as in the task of word).
sorry) I want to implement notification to admin when publishing articles from the front so as soon as someone added an article that appeared alert, as they will expect moderation. all done except for the notification) what you wrote I realized that I do not understand just how and where to store the number of notifications? in the database? or what?) - jaquelin_Litt commented on July 2nd 19 at 13:33
: Store in wp_options, say, a call option new_submissions. When creating a new post from the frontend it's value increase by 1, when viewing the post by the admin in the admin it's value by 1 decrease (all using update_option). Well, to display in menu item, then an arbitrary function is not needed, insert there get_option( 'new_submissions' ). All :) - Velva.Rogahn commented on July 2nd 19 at 13:36
Although, perhaps, there will be problems. I thought - you're not going to know for sure which of the posts the admin looked and should really decrease the counter by unity. Then option number 2 is to store options in an array of IDs of posts created from the front. On the withdrawal, respectively, will count( get_option( 'new_submissions' ) ), and when you open the edit page of the post you can check whether its ID in the array stored in options, and if Yes - uninstall it from there. So it will work without glitches. - Velva.Rogahn commented on July 2nd 19 at 13:39
: thank you) and how to check that the admin has viewed a new post?) - jaquelin_Litt commented on July 2nd 19 at 13:42
: Hocytes on admin-init, check which page (edit.php) and ID office. Next, see the administrator there and is there any post ID in your variable in the options. This is what immediately came to mind, maybe if you think and dig, there are some hook more convenient. But to work like it should. - Velva.Rogahn commented on July 2nd 19 at 13:45
: thank you) - jaquelin_Litt commented on July 2nd 19 at 13:48

Find more questions by tags WordPress