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
Related Posts:
- username_exists() function can’t be access without logging in
- Can i check if user is doing any ajax request?
- How to add default images into theme customizer image control?
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Validate a users email address when using gmail to register
- Click loads template via ajax
- How to speed up admin-ajax.php in wordpress
- get post based on category chosen in drop down – The ajax method
- How to store data from multiple forms using ajax and php
- PHP 8, AJAX mail form to function.php doesn’t work
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- Why ajax doesn’t work on certain wordpress hooks?
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- dynamic dependent select dropdown
- how to make custom ajax handler?
- How to disable controls in theme customizer?
- is_user_logged_in() not working in AJAX validation call
- Using data sent via AJAX in multiple functions on a WP plugin
- Function won’t run onclick using Ajax
- Why i can’t get custom fields value or post ID via Ajax?
- Post not populating for custom post type based on category selection
- How to get post category list as select in front-end?
- Is there a hack for using is_page() within the function.php file?
- Execute Jquery when a specific page in my plugin is loading
- AJAX function not working [closed]
- Disclaimer that will show every refresh of the page
- Database entry removed on browser refresh, Ajax PHP jQuery
- Store ajax data in PHP variable
- Multiple AJAX handler functions conflict in functions.php
- Ajax filter with loadmore button
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- register_block_type is not working properly
- get_the_author_meta( ‘ID’ ) just return 1
- Update $wpdb query with AJAX
- Can an AJAX callback function access a PHP variable which was defined during initial page load?
- WordPress Ajax filter: Create two loops for different output styles?
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- Offset with ajax load more posts duplicates
- ajaxurl usage for a custom function
- How to call a function from functions.php with ajax?
- Custom Post type Ajax search results
- Find the method which AJAX GET calls
- AJAX Returning Way Too Many Posts
- wordpress ajax return 0
- wp_delete_comment is doing nothing
- Modify category archive page loop on functions.php
- Registration form not registering First and Last name
- Modify php code to pass a page id as a parameter in order to create a breadcrumb
- ajax form function error
- AJAX: WordPress filters inside $html do not work as intended
- start_lvl Ignored in Custom walker_nav_menu
- Enforcing password complexity
- Check if a menu is empty?
- Dynamically change feature image in customiser
- Load custom field value into div with AJAX
- Creating wordpress user registration form
- Get the title before comma
- Accessing a random image via ajax
- category not display in word press grammatically
- Getting a fatal error while updating
- Display 4 chronological posts starting with a random post
- my function doesn’t return my post from today
- get_the_terms – only top level
- Have CSS Class Added with `is_page()` WP function
- Slide in Panel WordPress Post
- Use wp_get_recent_posts with search term
- comments_number display outside specified span
- Choose To Display Post Views With An Options Panel
- class click counter save number
- Passing the custom field values in the wp_get_current_user array function
- WordPress Sending data to Ajax with select option
- Get value from shortcode to do something
- How to create a php variable using WordPress the_title() function
- Can’t find infinite loop cause
- is there a benefit in using a constant over get_stylesheet_directory_uri?
- ::before on open/close function [closed]
- WordPress ajax-action failing because of newline in response
- REQUIRED: get_bloginfo(‘template_url’) was found in the file search.php. Use get_template_directory_uri() instead
- How to check if a PHP string is different than meta field?
- Creating a mobile site by adding a new class to the body tag from functions.php
- WP All Import / Update stock quantity from multiple XML files
- Calling PHP Scripts in Ajax that are in PHP Snippets
- How to style injected code in header section?
- Allow user to Upload image and manipulate it on the frontend
- SQL error with custom query
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Products listing check if meta checkbox is checked
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- Edit a function to take different actions based on user role
- How to put 2 php codes in functions.php without site crashing
- autocomplete in wordpress using ajax with json-data
- WP HTTP API call response
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Private messaging – Getting and displaying the avatar/url of a message recipient
- wordpress ajax pagination
- 500 (Internal Server Error) of external php file
- Fix My Custom Function: Remove Automatic
- WP Debug enabled Undefined index error in a widget
- Generate and upload screenshot as featured image for user-submitted post
- AJAX WP_Query’s order and orderby parameters not working