Skip to content

Instantly share code, notes, and snippets.

@jeremyfelt
Created February 7, 2019 18:31
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 jeremyfelt/98cabf0a8cde75b2a3e1b4783e651702 to your computer and use it in GitHub Desktop.
Save jeremyfelt/98cabf0a8cde75b2a3e1b4783e651702 to your computer and use it in GitHub Desktop.
Creating a notice in Gutenberg
// See https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/tutorials/notices/README.md
const {
dispatch,
} = wp.data;
const {
createWarningNotice,
} = dispatch( 'core/notices' );
createWarningNotice(
'Warning message',
{
isDismissible: false,
id: 'warningmessage',
actions: [
{
url: 'https://google.com',
label: 'This is a URL',
},
{
label: 'This is a button',
onClick: ( s ) => { console.log( s, 'this' ); },
className: 'custom_classname',
},
],
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment