From c6d7415d631cc4db7bc7e0722a7042a6895ce3bf Mon Sep 17 00:00:00 2001 From: Nikunj Hatkar Date: Sat, 20 Jun 2026 16:37:01 +0530 Subject: [PATCH 1/4] patch 45186 refresh --- src/wp-includes/default-filters.php | 4 ++++ src/wp-includes/functions.php | 33 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 5581828a10b61..418ba372c0fbb 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -702,6 +702,10 @@ add_action( 'load-post-new.php', 'wp_set_up_cross_origin_isolation' ); add_action( 'load-site-editor.php', 'wp_set_up_cross_origin_isolation' ); add_action( 'load-widgets.php', 'wp_set_up_cross_origin_isolation' ); + +//Move the admin notices below the heading tag via server-side processing. +add_action('admin_init', 'wp_move_notice_after_heading'); + // Nav menu. add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 ); add_filter( 'nav_menu_css_class', 'wp_nav_menu_remove_menu_item_has_children_class', 10, 4 ); diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 355d9f8a1ec37..0a7135689dd27 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -9280,6 +9280,39 @@ function wp_fast_hash( return '$generic$' . sodium_bin2base64( $hashed, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING ); } + /** + * Move the admin notices below the heading tag via server-side processing. + * This prevents the visual glitch caused by JavaScript processing in the original fix. + * + * @since 7.0.0 + */ +function wp_move_notice_after_heading() { + ob_start ( function( $html ) { + global $pagenow; + if ( ! class_exists( '\Dom\HTMLDocument' ) || empty( $html ) || ! is_string( $html ) || wp_doing_ajax() || ! is_user_logged_in() ) { + return $html; + } + + if ( 'admin-post.php' === $pagenow || ( defined( 'WP_CLI' ) && WP_CLI ) ) { + return $html; + } + + $dom = \Dom\HTMLDocument::createFromString( $html, LIBXML_NOERROR ); + $headerEnd = $dom->querySelector( '.wrap :is( h1, h2 )' ); + + $notices = $dom->querySelectorAll( 'div:is( .updated, .error, .notice ):not( .inline, .below-h2 )' ); + if ( $headerEnd && $notices->length > 0 ) { + foreach ( $notices as $notice ) { + $headerEnd->parentNode->insertBefore( $notice, $headerEnd->nextSibling ); + } + + return $dom->saveHTML(); + } + + return $html; + }); +} + /** * Checks whether a plaintext message matches the hashed value. Used to verify values hashed via wp_fast_hash(). * From dc59c03af33cb4e6d8b759b965969619bf4e90c9 Mon Sep 17 00:00:00 2001 From: Nikunj Hatkar Date: Tue, 23 Jun 2026 19:11:42 +0530 Subject: [PATCH 2/4] fix phpcs errors --- src/wp-includes/default-filters.php | 4 +-- src/wp-includes/functions.php | 56 ++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 418ba372c0fbb..c8b08cc62b957 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -703,8 +703,8 @@ add_action( 'load-site-editor.php', 'wp_set_up_cross_origin_isolation' ); add_action( 'load-widgets.php', 'wp_set_up_cross_origin_isolation' ); -//Move the admin notices below the heading tag via server-side processing. -add_action('admin_init', 'wp_move_notice_after_heading'); +// Move the admin notices below the heading tag via server-side processing. +add_action( 'admin_init', 'wp_move_notice_after_heading' ); // Nav menu. add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 ); diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 0a7135689dd27..6ee4ef46f7a31 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -9280,37 +9280,37 @@ function wp_fast_hash( return '$generic$' . sodium_bin2base64( $hashed, SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING ); } - /** - * Move the admin notices below the heading tag via server-side processing. +/** + * Move the admin notices below the heading tag via server-side processing. * This prevents the visual glitch caused by JavaScript processing in the original fix. - * - * @since 7.0.0 + * + * @since 7.x.x */ function wp_move_notice_after_heading() { - ob_start ( function( $html ) { - global $pagenow; - if ( ! class_exists( '\Dom\HTMLDocument' ) || empty( $html ) || ! is_string( $html ) || wp_doing_ajax() || ! is_user_logged_in() ) { - return $html; - } - - if ( 'admin-post.php' === $pagenow || ( defined( 'WP_CLI' ) && WP_CLI ) ) { - return $html; - } - - $dom = \Dom\HTMLDocument::createFromString( $html, LIBXML_NOERROR ); - $headerEnd = $dom->querySelector( '.wrap :is( h1, h2 )' ); - - $notices = $dom->querySelectorAll( 'div:is( .updated, .error, .notice ):not( .inline, .below-h2 )' ); - if ( $headerEnd && $notices->length > 0 ) { - foreach ( $notices as $notice ) { - $headerEnd->parentNode->insertBefore( $notice, $headerEnd->nextSibling ); - } - - return $dom->saveHTML(); - } - - return $html; - }); + ob_start ( function( $html ) { + global $pagenow; + if ( ! class_exists( '\Dom\HTMLDocument' ) || empty( $html ) || ! is_string( $html ) || wp_doing_ajax() || ! is_user_logged_in() ) { + return $html; + } + + if ( 'admin-post.php' === $pagenow || ( defined( 'WP_CLI' ) && WP_CLI ) ) { + return $html; + } + + $dom = \Dom\HTMLDocument::createFromString( $html, LIBXML_NOERROR ); + $headerEnd = $dom->querySelector( '.wrap :is( h1, h2 )' ); + + $notices = $dom->querySelectorAll( 'div:is( .updated, .error, .notice ):not( .inline, .below-h2 )' ); + if ( $headerEnd && $notices->length > 0 ) { + foreach ( $notices as $notice ) { + $headerEnd->parentNode->insertBefore( $notice, $headerEnd->nextSibling ); + } + + return $dom->saveHTML(); + } + + return $html; + }); } /** From e16400f98eb60e6560c9c6bc38b8d55207560963 Mon Sep 17 00:00:00 2001 From: Nikunj Hatkar Date: Tue, 23 Jun 2026 19:40:25 +0530 Subject: [PATCH 3/4] fix phpcs errors --- src/wp-includes/functions.php | 38 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 6ee4ef46f7a31..a753d818586cc 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -9287,30 +9287,32 @@ function wp_fast_hash( * @since 7.x.x */ function wp_move_notice_after_heading() { - ob_start ( function( $html ) { - global $pagenow; - if ( ! class_exists( '\Dom\HTMLDocument' ) || empty( $html ) || ! is_string( $html ) || wp_doing_ajax() || ! is_user_logged_in() ) { - return $html; - } + ob_start( + function ( $html ) { + global $pagenow; + if ( ! class_exists( '\Dom\HTMLDocument' ) || empty( $html ) || ! is_string( $html ) || wp_doing_ajax() || ! is_user_logged_in() ) { + return $html; + } - if ( 'admin-post.php' === $pagenow || ( defined( 'WP_CLI' ) && WP_CLI ) ) { - return $html; - } + if ( 'admin-post.php' === $pagenow || ( defined( 'WP_CLI' ) && WP_CLI ) ) { + return $html; + } - $dom = \Dom\HTMLDocument::createFromString( $html, LIBXML_NOERROR ); - $headerEnd = $dom->querySelector( '.wrap :is( h1, h2 )' ); + $dom = \Dom\HTMLDocument::createFromString( $html, LIBXML_NOERROR ); + $headerEnd = $dom->querySelector( '.wrap :is( h1, h2 )' ); - $notices = $dom->querySelectorAll( 'div:is( .updated, .error, .notice ):not( .inline, .below-h2 )' ); - if ( $headerEnd && $notices->length > 0 ) { - foreach ( $notices as $notice ) { - $headerEnd->parentNode->insertBefore( $notice, $headerEnd->nextSibling ); + $notices = $dom->querySelectorAll( 'div:is( .updated, .error, .notice ):not( .inline, .below-h2 )' ); + if ( $headerEnd && $notices->length > 0 ) { + foreach ( $notices as $notice ) { + $headerEnd->parentNode->insertBefore( $notice, $headerEnd->nextSibling ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- DOM API property name, cannot be renamed. + } + + return $dom->saveHTML(); } - return $dom->saveHTML(); + return $html; } - - return $html; - }); + ); } /** From 0a98341da9c38981b54e416ef0ecf70b61c05272 Mon Sep 17 00:00:00 2001 From: Nikunj Hatkar Date: Tue, 23 Jun 2026 19:46:49 +0530 Subject: [PATCH 4/4] adjusted phpdoc comment --- src/wp-includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index a753d818586cc..424a9ae26a0c6 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -9281,7 +9281,7 @@ function wp_fast_hash( } /** - * Move the admin notices below the heading tag via server-side processing. + * Moves the admin notices below the heading tag via server-side processing. * This prevents the visual glitch caused by JavaScript processing in the original fix. * * @since 7.x.x