Site-Wide Admin Notice
Shows your own message at the top of every admin screen, for example "This is the staging site" or a reminder for editors.
Opens WPIDE on
Code
$wpide_admin_notice = array(
'message' => '<strong>Heads up:</strong> content freeze until Friday. Please save changes as drafts.',
'type' => 'warning', // info, success, warning or error.
'capability' => 'edit_posts', // Who sees it.
);
add_action( 'admin_notices', function () use ( $wpide_admin_notice ) {
if ( ! current_user_can( $wpide_admin_notice['capability'] ) ) {
return;
}
printf(
'<div class="notice notice-%1$s"><p>%2$s</p></div>',
esc_attr( $wpide_admin_notice['type'] ),
wp_kses_post( $wpide_admin_notice['message'] )
);
} );
Notes
Deactivate the snippet to remove the notice; it cannot be dismissed by users.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.