Support » Plugins » Hacks » Moving admin submenu to top level

  • I’m trying to move a submenu from settings and make it a top level menu
    I tried using this but it is only rearranging top level menus

    function new_menu_order($new_order) {
    if (!$new_order) return true;
    return array(
    ‘index.php’,
    ‘edit.php’,
    ‘edit.php?post_type=page’,
    ‘upload.php’, //Media icon
    add_filter( ‘custom_menu_order’, array( $this, ‘new_menu_order’ ) );
    add_filter( ‘menu_order’, array( $this, ‘new_menu_order’ ) );

    any help will be appreciated

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Go ahead and add the top level menu using add_menu_page(). Remove the now duplicate submenu by using remove_submenu_page(). These functions should generally be executed by hooking the admin_menu action.

    If need be, you can determine the parameters needed by examining the global arrays $menu and $submenu. A bit hacky, but you could just manipulate these arrays directly using the same hook.

    yup, makes sense but what I did was empty out the toolbar and added what I wanted to it and then remove them from the admin menu

    Thanks for the help

    for those who may need this
    ///remove from toolbar///
    function wps_admin_bar() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu(‘wp-logo’);
    }
    add_action( ‘wp_before_admin_bar_render’, array($this, ‘wps_admin_bar’ ) );

    ///add to toolbar///
    function mytheme_admin_bar_render() {
    global $wp_admin_bar;
    $wp_admin_bar->add_menu( array(‘id’ => ‘id’,’title’ => __(‘Title’),’href’ => admin_url( ‘URL’)));
    }
    add_action( ‘wp_before_admin_bar_render’, array($this, ‘mytheme_admin_bar_render’ ) );

    ///remove from admin menu///
    function remove_menus() {
    global $menu;
    global $submenu;
    remove_menu_page( ‘users.php’ );
    }
    add_action( ‘admin_menu’, array( $this, ‘remove_menus’ ) );
    add_action( ‘admin_menu’, array( $this, ‘remove_submenus’ ) );

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Moving admin submenu to top level’ is closed to new replies.