Skip to content

Instantly share code, notes, and snippets.

@darinronne
Created August 23, 2017 16:07
Show Gist options
  • Save darinronne/79c9a535be93ea4f5c7b930127169f47 to your computer and use it in GitHub Desktop.
Save darinronne/79c9a535be93ea4f5c7b930127169f47 to your computer and use it in GitHub Desktop.
Wordpress: Insert Admin Menu Separator and Style Seperators
// Register Admin Menu Seperators
function m13_add_admin_menu_separator( $position ) {
global $menu;
$menu[ $position ] = array(
0 => '',
1 => 'read',
2 => 'separator' . $position,
3 => '',
4 => 'wp-menu-separator'
);
}
add_action( 'admin_init', 'm13_add_admin_menu_separator' );
// Insert Admin Menu Seperator
function m13_set_admin_menu_separator() {
// Make sure this number is different from a CPT menu_postion
// or else that CPT will be removed from the menu
do_action( 'admin_init', 26 ); // Insert after Comments
}
add_action( 'admin_menu', 'm13_set_admin_menu_separator' );
// Style the Admin Menu Seperators
function m13_style_admin_menu_separators() {
echo '<style type="text/css">#adminmenu li.wp-menu-separator {height: 2px; margin: 10px 0; background: rgba(255,255,255,0.15);}</style>';
}
add_action( 'admin_head', 'm13_style_admin_menu_separators' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment