Created
August 23, 2017 16:07
-
-
Save darinronne/79c9a535be93ea4f5c7b930127169f47 to your computer and use it in GitHub Desktop.
Wordpress: Insert Admin Menu Separator and Style Seperators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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