Created
October 17, 2021 02:56
-
-
Save kwcjr/39422f6834ed394df5c9532171d0916e to your computer and use it in GitHub Desktop.
This gist will create a persistent WP admin notice.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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