Skip to content

Commit

Permalink
Merge branch 'trunk' into 56791-coding-standards
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyBiryukov authored Dec 30, 2024
2 parents 9824852 + 2ba8433 commit c701bc1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/wp-admin/includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<table class="form-table" role="presentation">';
do_settings_fields( $page, $section['id'] );
echo '</table>';
}
echo '<table class="form-table" role="presentation">';
do_settings_fields( $page, $section['id'] );
echo '</table>';

if ( '' !== $section['after_section'] ) {
echo wp_kses_post( $section['after_section'] );
Expand Down
5 changes: 3 additions & 2 deletions src/wp-includes/ms-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ function get_active_blog_for_user( $user_id ) {
$ret = false;
if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
foreach ( (array) $blogs as $blog_id => $blog ) {
if ( get_current_network_id() !== (int) $blog->site_id ) {
if ( get_current_network_id() !== $blog->site_id ) {
continue;
}

$details = get_site( $blog_id );
if ( is_object( $details )
&& '0' === $details->archived && '0' === $details->spam && '0' === $details->deleted
) {
$ret = $details;
if ( (int) get_user_meta( $user_id, 'primary_blog', true ) !== (int) $blog_id ) {
if ( (int) get_user_meta( $user_id, 'primary_blog', true ) !== $blog_id ) {
update_user_meta( $user_id, 'primary_blog', $blog_id );
}
if ( ! get_user_meta( $user_id, 'source_domain', true ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ function get_post_ancestors( $post ) {

while ( $ancestor = get_post( $id ) ) {
// Loop detection: If the ancestor has been seen before, break.
if ( empty( $ancestor->post_parent ) || ( $ancestor->post_parent === $post->ID )
if ( empty( $ancestor->post_parent ) || $ancestor->post_parent === $post->ID
|| in_array( $ancestor->post_parent, $ancestors, true )
) {
break;
Expand Down
24 changes: 24 additions & 0 deletions tests/phpunit/tests/admin/includesTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,30 @@ public function test_add_settings_section_with_extra_args( $extra_args, $expecte
$this->assertStringContainsString( $expected_after_section_html, $output, 'Test page output does not contain the custom markup to be placed after the section.' );
}

/**
* @ticket 62746
*
* @param array $extra_args Extra arguments to pass to function `add_settings_section()`.
* @param array $expected_section_data Expected set of section data.
* @param string $expected_before_section_html Expected HTML markup to be rendered before the settings section.
* @param string $expected_after_section_html Expected HTML markup to be rendered after the settings section.
*
* @covers ::add_settings_section
* @covers ::do_settings_sections
*
* @dataProvider data_extra_args_for_add_settings_section
*/
public function test_add_settings_section_without_any_fields( $extra_args, $expected_section_data, $expected_before_section_html, $expected_after_section_html ) {
add_settings_section( 'test-section', 'Section title', '__return_false', 'test-page', $extra_args );

ob_start();
do_settings_sections( 'test-page' );
$output = ob_get_clean();

$this->assertStringContainsString( $expected_before_section_html, $output, 'Test page output does not contain the custom markup to be placed before the section.' );
$this->assertStringContainsString( $expected_after_section_html, $output, 'Test page output does not contain the custom markup to be placed after the section.' );
}

/**
* Data provider for `test_add_settings_section_with_extra_args()`.
*
Expand Down

0 comments on commit c701bc1

Please sign in to comment.