Example #1
0
/**
 * Sort the admin menu.
 *
 * @since 1.0.0
 */
function audiotheme_dashboard_sort_menu()
{
    global $menu;
    if (!is_network_admin() && $menu) {
        $menu = array_values($menu);
        // Re-key the array.
        $separator = array('', 'read', 'separator-before-audiotheme', '', 'wp-menu-separator');
        audiotheme_menu_insert_item($separator, 'audiotheme', 'before');
        // Reverse the order and always insert them after the main AudioTheme menu item.
        audiotheme_menu_move_item('edit.php?post_type=audiotheme_video', 'audiotheme');
        audiotheme_menu_move_item('edit.php?post_type=audiotheme_record', 'audiotheme');
        audiotheme_menu_move_item('audiotheme-gigs', 'audiotheme');
        audiotheme_submenu_move_after('audiotheme-settings', 'audiotheme', 'audiotheme');
    }
}
Example #2
0
/**
 * Move an existing menu item relative to another item.
 *
 * @since 1.0.0
 *
 * @param string $move_slug Slug of item to move.
 * @param string $relative_slug Slug of existing item.
 * @param string $position Optional. Defaults to 'after'. (before|after)
 */
function audiotheme_menu_move_item($move_slug, $relative_slug, $position = 'after')
{
    global $menu;
    $move_key = audiotheme_menu_get_item_key($move_slug);
    if ($move_key) {
        $item = $menu[$move_key];
        unset($menu[$move_key]);
        audiotheme_menu_insert_item($item, $relative_slug, $position);
    }
}