Return to Snippet

Revision: 72700
at November 1, 2017 08:33 by cusmin


Initial Code
add_action('admin_init', 'add_separators_admin_menu');

function add_separators_admin_menu()
{
    //ADD SEPARATORS AFTER THESE MENU ITEMS
    $separatorsAfter = ['Media', 'Plugins', 'Settings', 'WooCommerce'];
    ///////////////////////////////////////

    global $menu;
    if (is_admin()) {
        foreach((array) $separatorsAfter as $s){
            foreach ((array)$menu as $key => $item) {
                if (strpos($item[0], $s) !== false) {
                    array_splice($menu, $key+1, 0, array(array(
                        0 => '',
                        1 => 'read',
                        2 => 'separator-last',
                        3 => '',
                        4 => 'wp-menu-separator'
                    )));
                    break;
                }
            }
        }
    }
}

Initial URL

                                

Initial Description
Add this snippet to theme's functions.php
Add menu items that will have separator after them to $separatorsAfter array.

Initial Title
Add Separators in WordPress Admin Menu

Initial Tags
plugin

Initial Language
PHP