Skip to content

Instantly share code, notes, and snippets.

@TanvirHasan19
Created November 21, 2025 09:23
Show Gist options
  • Select an option

  • Save TanvirHasan19/891649ef58049a01c10b3ce71905d085 to your computer and use it in GitHub Desktop.

Select an option

Save TanvirHasan19/891649ef58049a01c10b3ce71905d085 to your computer and use it in GitHub Desktop.
JavaScript to DISABLE burger menu completely - show all items in main bar
/**
* JavaScript to DISABLE burger menu completely - show all items in main bar
* This prevents any items from being moved to the burger menu
*/
function wcv_disable_burger_menu() {
// Only run on dashboard pages
if ( ! function_exists( 'wcv_is_dashboard_page' ) || ! wcv_is_dashboard_page() ) {
return;
}
?>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
const extraMenu = $('.wcv-dashboard-menu.secondary');
const primaryMenu = $('.wcv-dashboard-menu.primary');
const toggleButton = $('#dashboard-menu-item-more-button');
// Function to move ALL items back to main menu and hide burger button
const disableBurgerMenu = function() {
// Move ALL items from burger menu back to main menu
extraMenu.find('li').each(function() {
$(this).appendTo(primaryMenu);
});
// Hide the burger menu button completely
toggleButton.hide();
extraMenu.hide();
};
// Run immediately and multiple times to catch all scenarios
disableBurgerMenu();
setTimeout(disableBurgerMenu, 100);
setTimeout(disableBurgerMenu, 300);
setTimeout(disableBurgerMenu, 600);
setTimeout(disableBurgerMenu, 1000);
// Run on window resize
$(window).on('resize', function() {
setTimeout(disableBurgerMenu, 100);
});
// Watch for any items being moved to burger menu and move them back
if (typeof MutationObserver !== 'undefined') {
const observer = new MutationObserver(function() {
disableBurgerMenu();
});
if (extraMenu.length) {
observer.observe(extraMenu[0], { childList: true, subtree: true });
}
if (primaryMenu.length) {
observer.observe(primaryMenu[0], { childList: true });
}
}
// Continuously check and move items back (every 300ms)
setInterval(function() {
if (extraMenu.find('li').length > 0) {
extraMenu.find('li').each(function() {
$(this).appendTo(primaryMenu);
});
toggleButton.hide();
extraMenu.hide();
}
}, 300);
// CSS to ensure burger menu stays hidden and menu items wrap if needed
$('<style>')
.prop('type', 'text/css')
.html(`
#dashboard-menu-item-more-button { display: none !important; }
.wcv-dashboard-menu.secondary { display: none !important; }
.wcv-dashboard-menu.primary {
display: flex !important;
flex-wrap: wrap !important;
}
.wcv-dashboard-menu.primary li {
flex-shrink: 0;
}
`)
.appendTo('head');
});
})(jQuery);
</script>
<?php
}
add_action( 'wp_footer', 'wcv_disable_burger_menu', 999 ); // High priority
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment