Skip to content

Commit

Permalink
Only render the latest notice in wp admin pages
Browse files Browse the repository at this point in the history
  • Loading branch information
wpalani committed Apr 24, 2024
1 parent 0f90aef commit 475da95
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 475da95

Please sign in to comment.