From 1cd69de5dafa6297d70bb040c2a82df3cddc13e9 Mon Sep 17 00:00:00 2001 From: Alex Goller Date: Sat, 28 Dec 2024 15:00:45 +0700 Subject: [PATCH] Update conditional check for settings_fields in settings_section When a section did not have fields attached, the loop moved to the next item. This change makes sure the `after_section` argument gets printed. --- src/wp-admin/includes/template.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 3bff8bc279b5f..a0d07696d3019 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -1784,12 +1784,11 @@ function do_settings_sections( $page ) { call_user_func( $section['callback'], $section ); } - if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) { - continue; + if ( isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) { + echo ''; + do_settings_fields( $page, $section['id'] ); + echo ''; } - echo ''; - do_settings_fields( $page, $section['id'] ); - echo ''; if ( '' !== $section['after_section'] ) { echo wp_kses_post( $section['after_section'] );