Skip to content

Instantly share code, notes, and snippets.

@kwcjr
Created October 17, 2021 02:56
Show Gist options
  • Save kwcjr/39422f6834ed394df5c9532171d0916e to your computer and use it in GitHub Desktop.
Save kwcjr/39422f6834ed394df5c9532171d0916e to your computer and use it in GitHub Desktop.
This gist will create a persistent WP admin notice.
add_filter( 'admin_notices', 'my_remote_admin_notice' );
add_filter( 'network_admin_notices', 'my_remote_admin_notice' );
function my_remote_admin_notice() {
$notice_url = 'INSERT_URL_HERE';
$message = json_decode( wp_remote_retrieve_body( wp_remote_get( $notice_url ) ), true)['content']['rendered'];
if( is_wp_error( $message ) ) {
return false;
}
?>
<div class="notice notice-success is-dismissible admin-notice-remote">
<div class="notice-content">
<?php echo $message; ?>
</div>
<button type="button" class="notice-dismiss">
<span class="screen-reader-text">Dismiss this notice.</span>
</button>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment