Here is a neat function you can call to display notices in the admin panel.
function display_admin_notice($class='updated', $message) { global $notice; $notice = '<div class="'.$class.'"> <p>'.$message.'</p></div>'; add_action('admin_notices', function() { global $notice; echo $notice; }); } |
Change class to ‘error’ or ‘update-nag’ etc…
display_admin_notice('error', 'You cannot be serious!'); |
Ref – https://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices
Be First to Comment