Created
February 14, 2017 14:10
-
-
Save gfargo/326daf65539dc67a19daa46706d73a47 to your computer and use it in GitHub Desktop.
WP-Admin Notification Class
This file contains 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 | |
/** | |
* Creates Messages for WP Admin Screens | |
* | |
* @author gfargo | |
*/ | |
class Admin_Message { | |
/** | |
* Alert Message | |
*/ | |
private $_message; | |
/** | |
* Alert Class | |
*/ | |
private $_class; | |
public function __construct( $message, $class = 'notice notice-error' ) { | |
$this->_message = $message; | |
$this->_class = $class; | |
add_action( 'admin_notices', array( $this, 'render' ) ); | |
} | |
public function render() { | |
printf( '<div class="%1$s"><p>%2$s</p></div>', $this->_class, $this->_message ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment