Skip to content

Commit

Permalink
Merge pull request #22 from newfold-labs/update/one-notice-only
Browse files Browse the repository at this point in the history
Only render one notice (the latest) in wp admin
  • Loading branch information
wpalani authored Apr 25, 2024
2 parents 0f90aef + 475da95 commit 3c8a64c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions includes/AdminNotices.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ public static function maybeRenderAdminNotices() {
self::openContainer();

if ( $collection->count() ) {
$collection->each(
function ( Notification $notification ) use ( $page ) {
if ( $notification->shouldShow( 'wp-admin-notice', array( 'page' => $page ) ) ) {
?>
<div class="newfold-notice" data-id="<?php echo esc_attr( $notification->id ); ?>">
<?php echo $notification->content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php
}
// Only show the latest notification that should be shown on this page
foreach ( $collection as $notification ) {
if ( $notification->shouldShow( 'wp-admin-notice', array( 'page' => $page ) ) ) {
?>
<div class="newfold-notice" data-id="<?php echo esc_attr( $notification->id ); ?>">
<?php echo $notification->content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
<?php
break;
}
);
}
}

self::closeContainer();
Expand Down

0 comments on commit 3c8a64c

Please sign in to comment.