Skip to content

Instantly share code, notes, and snippets.

@lgedeon
Created August 22, 2017 13:10
Show Gist options
  • Save lgedeon/0cbadda43a932472e1bcf1d74e0a96d1 to your computer and use it in GitHub Desktop.
Save lgedeon/0cbadda43a932472e1bcf1d74e0a96d1 to your computer and use it in GitHub Desktop.
Wrong approach maybe some usable pieces.
<?php
/**
* Display our notice and hide default.
*/
function action_admin_notices() {
$screen = get_current_screen();
if ( ! in_array( $screen->id, array( 'post', 'page' ), true ) ) {
return;
}
$post = get_post();
$message = get_post_meta( $post->ID, self::META_KEY, true );
// Add our error message and hide default WP success message.
if ( $message ) { ?>
<div class="notice notice-error is-dismissible">
<p><?php echo esc_html( $message ); ?></p>
</div>
<script>jQuery(document).ready(function(jQuery){jQuery('#message.notice-success').hide();});</script>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment