Skip to content

Instantly share code, notes, and snippets.

@thefuxia
Last active September 17, 2021 15:25
Show Gist options
  • Save thefuxia/4432959 to your computer and use it in GitHub Desktop.
Save thefuxia/4432959 to your computer and use it in GitHub Desktop.
T5 Hide dead menu metaboxesWordPress Plugin to improve the menu management screen.
<?php
/**
* Plugin Name: T5 Hide dead menu metaboxes
* Description: Do not show menu metaboxes when no nav menu exists.
* Plugin URI: https://gist.github.com/thefuxia/4432959
* Version: 2013.01.02
* Author: Fuxia Scholz
* Author URI: https://fuxia.me
* Licence: MIT
* License URI: http://opensource.org/licenses/MIT
*/
add_action( 'admin_head-nav-menus.php', 't5_hide_dead_menu_metaboxes' );
/**
* Remove metaboxes for menu items when no menu exists.
*
* @wp-hook admin_head-nav-menus.php
* @return void
*/
function t5_hide_dead_menu_metaboxes()
{
if ( empty ( $GLOBALS['nav_menus'] ) )
{
$GLOBALS['wp_meta_boxes']['nav-menus'] = array ();
echo '<style>#nav-menus-frame{margin-left:0 !important;padding-top:20px}</style>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment