Skip to content

Commit 3bf16aa

Browse files
committed
Menus: Remove bulk action checkboxes when menu is empty.
This changeset removes the bulk action checkboxes when there is no menu item to select. Follow-up to [51006], [51539]. Props oglekler, krishaweb, costdev, Boniu91, hugodevos, audrasjb. Fixes #54799. See #21603, #53654. git-svn-id: https://develop.svn.wordpress.org/trunk@54316 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5063b8d commit 3bf16aa

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/js/_enqueues/lib/nav-menu.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,4 +1557,19 @@
15571557
});
15581558
});
15591559

1560+
// Show bulk action
1561+
$( document ).on( 'menu-item-added', function() {
1562+
if ( ! $( '.bulk-actions' ).is( ':visible' ) ) {
1563+
$( '.bulk-actions' ).show();
1564+
}
1565+
} );
1566+
1567+
// Hide bulk action
1568+
$( document ).on( 'menu-removing-item', function( e, el ) {
1569+
var menuElement = $( el ).parents( '#menu-to-edit' );
1570+
if ( menuElement.find( 'li' ).length === 1 && $( '.bulk-actions' ).is( ':visible' ) ) {
1571+
$( '.bulk-actions' ).hide();
1572+
}
1573+
} );
1574+
15601575
})(jQuery);

src/wp-admin/nav-menus.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ function wp_nav_menu_max_depth( $classes ) {
10001000
</div>
10011001

10021002
<?php if ( ! $add_new_screen ) : ?>
1003-
<div id="nav-menu-bulk-actions-top" class="bulk-actions">
1003+
<div id="nav-menu-bulk-actions-top" class="bulk-actions" <?php echo $hide_style; ?>>
10041004
<label class="bulk-select-button" for="bulk-select-switcher-top">
10051005
<input type="checkbox" id="bulk-select-switcher-top" name="bulk-select-switcher-top" class="bulk-select-switcher">
10061006
<span class="bulk-select-button-label"><?php _e( 'Bulk Select' ); ?></span>
@@ -1035,7 +1035,7 @@ function wp_nav_menu_max_depth( $classes ) {
10351035
?>
10361036

10371037
<?php if ( ! $add_new_screen ) : ?>
1038-
<div id="nav-menu-bulk-actions-bottom" class="bulk-actions">
1038+
<div id="nav-menu-bulk-actions-bottom" class="bulk-actions" <?php echo $hide_style; ?>>
10391039
<label class="bulk-select-button" for="bulk-select-switcher-bottom">
10401040
<input type="checkbox" id="bulk-select-switcher-bottom" name="bulk-select-switcher-top" class="bulk-select-switcher">
10411041
<span class="bulk-select-button-label"><?php _e( 'Bulk Select' ); ?></span>

0 commit comments

Comments
 (0)