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
This commit is contained in:
Jb Audras 2022-03-29 15:57:05 +00:00
parent ecfcb3e885
commit 48e814e6bf

View File

@ -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 );
}