--- a/wp/wp-admin/nav-menus.php Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/nav-menus.php Wed Sep 21 18:19:35 2022 +0200
@@ -316,6 +316,7 @@
check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
// Merge new and existing menu locations if any new ones are set.
+ $new_menu_locations = array();
if ( isset( $_POST['menu-locations'] ) ) {
$new_menu_locations = array_map( 'absint', $_POST['menu-locations'] );
$menu_locations = array_merge( $menu_locations, $new_menu_locations );
@@ -339,15 +340,6 @@
wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) );
}
- // Set the menu_location value correctly for the newly created menu.
- foreach ( $menu_locations as $location => $id ) {
- if ( 0 === $id ) {
- $menu_locations[ $location ] = $nav_menu_selected_id;
- }
- }
-
- set_theme_mod( 'nav_menu_locations', $menu_locations );
-
if ( isset( $_REQUEST['zero-menu-state'] ) || ! empty( $_POST['auto-add-pages'] ) ) {
// If there are menu items, add them.
wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title );
@@ -363,6 +355,15 @@
}
set_theme_mod( 'nav_menu_locations', $locations );
+ } elseif ( count( $new_menu_locations ) > 0 ) {
+ // If locations have been selected for the new menu, save those.
+ $locations = get_nav_menu_locations();
+
+ foreach ( array_keys( $new_menu_locations ) as $location ) {
+ $locations[ $location ] = $nav_menu_selected_id;
+ }
+
+ set_theme_mod( 'nav_menu_locations', $locations );
}
if ( isset( $_REQUEST['use-location'] ) ) {
@@ -424,7 +425,7 @@
// If the menu ID changed, redirect to the new URL.
if ( $nav_menu_selected_id !== $_nav_menu_selected_id ) {
- wp_redirect( admin_url( 'nav-menus.php?menu=' . intval( $_nav_menu_selected_id ) ) );
+ wp_redirect( admin_url( 'nav-menus.php?menu=' . (int) $_nav_menu_selected_id ) );
exit;
}
}
@@ -494,6 +495,10 @@
'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: %s: Item name. */
+ 'menuItemDeletion' => __( 'item %s' ),
+ /* translators: %s: Item name. */
+ 'itemsDeleted' => __( 'Deleted menu item: %s.' ),
);
wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n );
@@ -596,8 +601,8 @@
/* translators: 1: URL to Widgets screen, 2 and 3: The names of the default themes. */
__( 'Menus can be displayed in locations defined by your theme, even used in sidebars by adding a “Navigation Menu” widget on the <a href="%1$s">Widgets</a> screen. If your theme does not support the navigation menus feature (the default themes, %2$s and %3$s, do), you can learn about adding this support by following the Documentation link to the side.' ),
admin_url( 'widgets.php' ),
- 'Twenty Nineteen',
- 'Twenty Twenty'
+ 'Twenty Twenty',
+ 'Twenty Twenty-One'
) . '</p>';
$overview .= '<p>' . __( 'From this screen you can:' ) . '</p>';
$overview .= '<ul><li>' . __( 'Create, edit, and delete menus' ) . '</li>';
@@ -663,7 +668,7 @@
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
<div class="wrap">
- <h1 class="wp-heading-inline"><?php echo esc_html( __( 'Menus' ) ); ?></h1>
+ <h1 class="wp-heading-inline"><?php esc_html_e( 'Menus' ); ?></h1>
<?php
if ( current_user_can( 'customize' ) ) :
$focus = $locations_screen ? array( 'section' => 'menu_locations' ) : array( 'panel' => 'nav_menus' );
@@ -694,7 +699,7 @@
<hr class="wp-header-end">
<nav class="nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
- <a href="<?php echo admin_url( 'nav-menus.php' ); ?>" class="nav-tab<?php echo $nav_tab_active_class; ?>"<?php echo $nav_aria_current; ?>><?php esc_html_e( 'Edit Menus' ); ?></a>
+ <a href="<?php echo esc_url( admin_url( 'nav-menus.php' ) ); ?>" class="nav-tab<?php echo $nav_tab_active_class; ?>"<?php echo $nav_aria_current; ?>><?php esc_html_e( 'Edit Menus' ); ?></a>
<?php
if ( $num_locations && $menu_count ) {
$active_tab_class = '';
@@ -845,7 +850,7 @@
<span class="screen-reader-text"><?php _e( 'Click the Save Menu button to save your changes.' ); ?></span>
</span><!-- /add-edit-menu-action -->
<?php else : ?>
- <form method="get" action="<?php echo admin_url( 'nav-menus.php' ); ?>">
+ <form method="get" action="<?php echo esc_url( admin_url( 'nav-menus.php' ) ); ?>">
<input type="hidden" name="action" value="edit" />
<label for="select-menu-to-edit" class="selected-menu"><?php _e( 'Select a menu to edit:' ); ?></label>
<select name="menu" id="select-menu-to-edit">
@@ -961,7 +966,7 @@
<div id="nav-menu-header">
<div class="major-publishing-actions wp-clearfix">
<label class="menu-name-label" for="menu-name"><?php _e( 'Menu Name' ); ?></label>
- <input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox" <?php echo $menu_name_val . $menu_name_aria_desc; ?> />
+ <input name="menu-name" id="menu-name" type="text" class="menu-name regular-text menu-item-textbox form-required" required="required" <?php echo $menu_name_val . $menu_name_aria_desc; ?> />
<div class="publishing-action">
<?php submit_button( empty( $nav_menu_selected_id ) ? __( 'Create Menu' ) : __( 'Save Menu' ), 'primary large menu-save', 'save_menu', false, array( 'id' => 'save_menu_header' ) ); ?>
</div><!-- END .publishing-action -->
@@ -970,7 +975,6 @@
<div id="post-body">
<div id="post-body-content" class="wp-clearfix">
<?php if ( ! $add_new_screen ) : ?>
-
<?php
$hide_style = '';
@@ -988,6 +992,15 @@
<p><?php echo $starter_copy; ?></p>
</div>
+ <?php if ( ! $add_new_screen ) : ?>
+ <div id="nav-menu-bulk-actions-top" class="bulk-actions">
+ <label class="bulk-select-button" for="bulk-select-switcher-top">
+ <input type="checkbox" id="bulk-select-switcher-top" name="bulk-select-switcher-top" class="bulk-select-switcher">
+ <span class="bulk-select-button-label"><?php _e( 'Bulk Select' ); ?></span>
+ </label>
+ </div>
+ <?php endif; ?>
+
<?php
if ( isset( $edit_markup ) && ! is_wp_error( $edit_markup ) ) {
echo $edit_markup;
@@ -1013,6 +1026,21 @@
$no_menus_style = 'style="display: none;"';
}
?>
+
+ <?php if ( ! $add_new_screen ) : ?>
+ <div id="nav-menu-bulk-actions-bottom" class="bulk-actions">
+ <label class="bulk-select-button" for="bulk-select-switcher-bottom">
+ <input type="checkbox" id="bulk-select-switcher-bottom" name="bulk-select-switcher-top" class="bulk-select-switcher">
+ <span class="bulk-select-button-label"><?php _e( 'Bulk Select' ); ?></span>
+ </label>
+ <input type="button" class="deletion menu-items-delete disabled" value="<?php _e( 'Remove Selected Items' ); ?>">
+ <div id="pending-menu-items-to-delete">
+ <p><?php _e( 'List of menu items selected for deletion:' ); ?></p>
+ <ul></ul>
+ </div>
+ </div>
+ <?php endif; ?>
+
<div class="menu-settings" <?php echo $no_menus_style; ?>>
<h3><?php _e( 'Menu Settings' ); ?></h3>
<?php
@@ -1042,7 +1070,14 @@
<legend class="menu-settings-group-name howto"><?php _e( 'Display location' ); ?></legend>
<?php
foreach ( $locations as $location => $description ) :
- $checked = isset( $menu_locations[ $location ] ) && $menu_locations[ $location ] === $nav_menu_selected_id;
+ $checked = false;
+
+ if ( isset( $menu_locations[ $location ] )
+ && 0 !== $nav_menu_selected_id
+ && $menu_locations[ $location ] === $nav_menu_selected_id
+ ) {
+ $checked = true;
+ }
?>
<div class="menu-settings-input checkbox-input">
<input type="checkbox"<?php checked( $checked ); ?> name="menu-locations[<?php echo esc_attr( $location ); ?>]" id="locations-<?php echo esc_attr( $location ); ?>" value="<?php echo esc_attr( $nav_menu_selected_id ); ?>" />