Last active
December 25, 2015 13:29
-
-
Save andrezrv/6984145 to your computer and use it in GitHub Desktop.
How to display a notice in the admin section of WordPress.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Displays a notice in the admin section under some condition. | |
* | |
* @author andrezrv | |
*/ | |
function my_admin_notice() { | |
global $current_screen; | |
if ( $current_screen->parent_base == 'options-general' ) { // Or whatever. | |
$html = '<div class="error"><p><strong>OMFG!</strong> Something really really bad just happened! D:</p></div>'; | |
echo $html; | |
} | |
} | |
add_action( 'admin_notices', 'my_admin_notice' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment