Skip to content

Commit 44c8433

Browse files
committed
Update settings_errors conditional logic to check for settings_page_ prefix
- Replace parent_base check with screen base check for better accuracy - Prevents duplicate settings notices on WordPress settings pages - Updated in all class-settings-api.php files across repositories
1 parent d2c6bbe commit 44c8433

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

includes/admin/settings/class-settings-api.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,15 @@ public function plugin_settings() {
945945
<?php do_action( $this->prefix . '_settings_page_header_before' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound ?>
946946
<h1><?php echo esc_html( $this->translation_strings['page_header'] ); ?></h1>
947947
<?php do_action( $this->prefix . '_settings_page_header' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound ?>
948-
<?php settings_errors( $this->prefix . '-notices' ); ?>
948+
949+
<?php
950+
// WordPress automatically calls settings_errors() on Settings pages.
951+
// Only call it manually on custom menu pages to prevent duplicates.
952+
$current_screen = get_current_screen();
953+
if ( $current_screen && 0 !== strpos( $current_screen->base, 'settings_page_' ) ) {
954+
settings_errors( $this->prefix . '-notices' );
955+
}
956+
?>
949957

950958
<div id="poststuff">
951959
<div id="post-body" class="metabox-holder columns-2">

0 commit comments

Comments
 (0)