Skip to content

Instantly share code, notes, and snippets.

@isuke01
Last active November 20, 2017 13:50
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 isuke01/cfff212ced582f91f7d03eca7b839c24 to your computer and use it in GitHub Desktop.
Save isuke01/cfff212ced582f91f7d03eca7b839c24 to your computer and use it in GitHub Desktop.
WP_admin simple notice JS
/**
* admin_notice(desc, type, dismissable)
*
* @param string desc: descriotion text for notice
* @param string type: oneof [success, error, warning, info]
* @param bool dismissable: should be dismissable or dont
*/
function admin_notice(desc, type, dismissable) {
if (dismissable) {
dismissable = 'is-dismissible';
dismissable_html = '<button onClick="event.target.parentNode.remove()" type="button" class="notice-dismiss">';
} else {
dismissable = '';
dismissable_html = '';
}
return '<div class="settings-messages"><div class="notice notice-'+type+' '+dismissable+'"><p>'+desc+'</p>'+dismissable_html+'<span class="screen-reader-text">Status notice</span></button></div></div>'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment