diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/nav-menus.php
--- a/wp/wp-admin/nav-menus.php Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-admin/nav-menus.php Fri Sep 05 18:40:08 2025 +0200
@@ -28,6 +28,9 @@
);
}
+// Used in the HTML title tag.
+$title = __( 'Menus' );
+
wp_enqueue_script( 'nav-menu' );
if ( wp_is_mobile() ) {
@@ -117,6 +120,10 @@
if ( ! is_wp_error( $parent_object ) ) {
$parent_data = (array) $parent_object;
$menu_item_data['menu_item_parent'] = $parent_data['menu_item_parent'];
+
+ // Reset invalid `menu_item_parent`.
+ $menu_item_data = _wp_reset_invalid_menu_item_parent( $menu_item_data );
+
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
}
@@ -126,6 +133,10 @@
$menu_item_data['menu_order'] = $menu_item_data['menu_order'] + 1;
$menu_item_data['menu_item_parent'] = $next_item_data['ID'];
+
+ // Reset invalid `menu_item_parent`.
+ $menu_item_data = _wp_reset_invalid_menu_item_parent( $menu_item_data );
+
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
wp_update_post( $menu_item_data );
@@ -137,6 +148,10 @@
&& in_array( (int) $menu_item_data['menu_item_parent'], $orders_to_dbids, true )
) {
$menu_item_data['menu_item_parent'] = (int) get_post_meta( $menu_item_data['menu_item_parent'], '_menu_item_menu_item_parent', true );
+
+ // Reset invalid `menu_item_parent`.
+ $menu_item_data = _wp_reset_invalid_menu_item_parent( $menu_item_data );
+
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
}
}
@@ -247,6 +262,10 @@
) {
// Just make it a child of the previous; keep the order.
$menu_item_data['menu_item_parent'] = (int) $orders_to_dbids[ $dbids_to_orders[ $menu_item_id ] - 1 ];
+
+ // Reset invalid `menu_item_parent`.
+ $menu_item_data = _wp_reset_invalid_menu_item_parent( $menu_item_data );
+
update_post_meta( $menu_item_data['ID'], '_menu_item_menu_item_parent', (int) $menu_item_data['menu_item_parent'] );
wp_update_post( $menu_item_data );
}
@@ -262,7 +281,14 @@
check_admin_referer( 'delete-menu_item_' . $menu_item_id );
if ( is_nav_menu_item( $menu_item_id ) && wp_delete_post( $menu_item_id, true ) ) {
- $messages[] = '
' . __( 'The menu item has been successfully deleted.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'The menu item has been successfully deleted.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
}
break;
@@ -283,9 +309,23 @@
}
if ( is_wp_error( $deletion ) ) {
- $messages[] = '' . $deletion->get_error_message() . '
';
+ $messages[] = wp_get_admin_notice(
+ $deletion->get_error_message(),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ 'dismissible' => true,
+ )
+ );
} else {
- $messages[] = '' . __( 'The menu has been successfully deleted.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'The menu has been successfully deleted.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
}
break;
@@ -301,13 +341,27 @@
$deletion = wp_delete_nav_menu( $menu_id_to_delete );
if ( is_wp_error( $deletion ) ) {
- $messages[] = '' . $deletion->get_error_message() . '
';
+ $messages[] = wp_get_admin_notice(
+ $deletion->get_error_message(),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ 'dismissible' => true,
+ )
+ );
$deletion_error = true;
}
}
if ( empty( $deletion_error ) ) {
- $messages[] = '' . __( 'Selected menus have been successfully deleted.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'Selected menus have been successfully deleted.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
}
break;
@@ -330,7 +384,14 @@
$_nav_menu_selected_id = wp_update_nav_menu_object( 0, array( 'menu-name' => $new_menu_title ) );
if ( is_wp_error( $_nav_menu_selected_id ) ) {
- $messages[] = '' . $_nav_menu_selected_id->get_error_message() . '
';
+ $messages[] = wp_get_admin_notice(
+ $_nav_menu_selected_id->get_error_message(),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ 'dismissible' => true,
+ )
+ );
} else {
$_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
$nav_menu_selected_id = $_nav_menu_selected_id;
@@ -381,7 +442,14 @@
exit;
}
} else {
- $messages[] = '' . __( 'Please enter a valid menu name.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'Please enter a valid menu name.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ 'dismissible' => true,
+ )
+ );
}
// Update existing menu.
@@ -403,7 +471,14 @@
$menu_title = trim( esc_html( $_POST['menu-name'] ) );
if ( ! $menu_title ) {
- $messages[] = '' . __( 'Please enter a valid menu name.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'Please enter a valid menu name.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ 'dismissible' => true,
+ )
+ );
$menu_title = $_menu_object->name;
}
@@ -412,7 +487,14 @@
if ( is_wp_error( $_nav_menu_selected_id ) ) {
$_menu_object = $_nav_menu_selected_id;
- $messages[] = '' . $_nav_menu_selected_id->get_error_message() . '
';
+ $messages[] = wp_get_admin_notice(
+ $_nav_menu_selected_id->get_error_message(),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ 'dismissible' => true,
+ )
+ );
} else {
$_menu_object = wp_get_nav_menu_object( $_nav_menu_selected_id );
$nav_menu_selected_title = $_menu_object->name;
@@ -449,7 +531,14 @@
// Set menu locations.
set_theme_mod( 'nav_menu_locations', $menu_locations );
- $messages[] = '' . __( 'Menu locations updated.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'Menu locations updated.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
}
break;
@@ -491,10 +580,12 @@
'under' => __( 'Under %s' ),
/* translators: %s: Previous item name. */
'outFrom' => __( 'Out from under %s' ),
- /* translators: 1: Item name, 2: Item position, 3: Total number of items. */
- 'menuFocus' => __( '%1$s. Menu item %2$d of %3$d.' ),
- /* translators: 1: Item name, 2: Item position, 3: Parent item name. */
- 'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ),
+ /* translators: 1: Item name, 2: Item type, 3: Item index, 4: Total items. */
+ 'menuFocus' => __( 'Edit %1$s (%2$s, %3$d of %4$d)' ),
+ /* translators: 1: Item name, 2: Item type, 3: Item index, 4: Total items, 5: Item parent. */
+ 'subMenuFocus' => __( 'Edit %1$s (%2$s, sub-item %3$d of %4$d under %5$s)' ),
+ /* translators: 1: Item name, 2: Item type, 3: Item index, 4: Total items, 5: Item parent, 6: Item depth. */
+ 'subMenuMoreDepthFocus' => __( 'Edit %1$s (%2$s, sub-item %3$d of %4$d under %5$s, level %6$d)' ),
/* translators: %s: Item name. */
'menuItemDeletion' => __( 'item %s' ),
/* translators: %s: Item name. */
@@ -595,11 +686,19 @@
wp_initial_nav_menu_meta_boxes();
if ( ! current_theme_supports( 'menus' ) && ! $num_locations ) {
- $messages[] = '' . sprintf(
+ $message_no_theme_support = sprintf(
/* translators: %s: URL to Widgets screen. */
__( 'Your theme does not natively support menus, but you can use them in sidebars by adding a “Navigation Menu” widget on the Widgets screen.' ),
admin_url( 'widgets.php' )
- ) . '
';
+ );
+ $messages[] = wp_get_admin_notice(
+ $message_no_theme_support,
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
}
if ( ! $locations_screen ) : // Main tab.
@@ -624,7 +723,7 @@
);
$menu_management = '' . __( 'The menu management box at the top of the screen is used to control which menu is opened in the editor below.' ) . '
';
- $menu_management .= '- ' . __( 'To edit an existing menu, choose a menu from the drop down and click Select' ) . '
';
+ $menu_management .= '- ' . __( 'To edit an existing menu, choose a menu from the dropdown and click Select' ) . '
';
$menu_management .= '- ' . __( 'If you have not yet created any menus, click the ’create a new menu’ link to get started' ) . '
';
$menu_management .= '' . __( 'You can assign theme locations to individual menus by selecting the desired settings at the bottom of the menu editor. To assign menus to all theme locations at once, visit the Manage Locations tab at the top of the screen.' ) . '
';
@@ -652,7 +751,7 @@
);
else : // Locations tab.
$locations_overview = '' . __( 'This screen is used for globally assigning menus to locations defined by your theme.' ) . '
';
- $locations_overview .= '- ' . __( 'To assign menus to one or more theme locations, select a menu from each location’s drop down. When you are finished, click Save Changes' ) . '
';
+ $locations_overview .= '- ' . __( 'To assign menus to one or more theme locations, select a menu from each location’s dropdown. When you are finished, click Save Changes' ) . '
';
$locations_overview .= '- ' . __( 'To edit a menu currently assigned to a theme location, click the adjacent ’Edit’ link' ) . '
';
$locations_overview .= '- ' . __( 'To add a new menu instead of assigning an existing one, click the ’Use new menu’ link. Your new menu will be automatically assigned to that theme location' ) . '
';
@@ -667,8 +766,8 @@
get_current_screen()->set_help_sidebar(
'' . __( 'For more information:' ) . '
' .
- '' . __( 'Documentation on Menus' ) . '
' .
- '' . __( 'Support' ) . '
'
+ '' . __( 'Documentation on Menus' ) . '
' .
+ '' . __( 'Support forums' ) . '
'
);
// Get the admin header.
@@ -789,7 +888,12 @@
);
?>
">
-
+
+
+
@@ -835,7 +939,12 @@
-