From 48e814e6bf42e20715f18fa995225f4556d64131 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Tue, 29 Mar 2022 15:57:05 +0000 Subject: [PATCH] Administration: Do not specify menu order for the Widgets menu when the active theme is a block theme. When using a block theme that declares Widgets support, it's better to not specify a menu order for the Widgets menu to avoid conflicts between menu items order. Props Rufus87, ironprogrammer, audrasjb, hellofromTonya, davidbaumwald. Fixes #54916. git-svn-id: https://develop.svn.wordpress.org/trunk@53020 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 0e0f626e56..8923cc23f3 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -5226,6 +5226,7 @@ function wp_maybe_load_widgets() { * Append the Widgets menu to the themes main menu. * * @since 2.2.0 + * @since 5.9.3 Don't specify menu order when the active theme is a block theme. * * @global array $submenu */ @@ -5236,7 +5237,13 @@ function wp_widgets_add_menu() { return; } - $submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' ); + $menu_name = __( 'Widgets' ); + if ( wp_is_block_theme() ) { + $submenu['themes.php'][] = array( $menu_name, 'edit_theme_options', 'widgets.php' ); + } else { + $submenu['themes.php'][7] = array( $menu_name, 'edit_theme_options', 'widgets.php' ); + } + ksort( $submenu['themes.php'], SORT_NUMERIC ); }