Skip to content

Instantly share code, notes, and snippets.

@gfargo
Created February 14, 2017 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfargo/326daf65539dc67a19daa46706d73a47 to your computer and use it in GitHub Desktop.
Save gfargo/326daf65539dc67a19daa46706d73a47 to your computer and use it in GitHub Desktop.
WP-Admin Notification Class
<?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