How to activate “Description” metabox for menu item programmatically?

I’m creating custom wordpress theme. How can I enable “Description” metabox for menu items (on nav-menu page) by default programmatically?

Related posts

Leave a Reply

2 comments

  1. Remove the description from the user meta value managenav-menuscolumnshidden:

    add_filter( 'manage_nav-menus_columns', 'enable_nav_menu_description_by_default' );
    
    function enable_nav_menu_description_by_default( $columns )
    {
        $desc_key = 'managenav-menuscolumnshidden';
        $hidden   = get_user_option( $desc_key );
        $user_id  = wp_get_current_user()->ID;
    
        if ( ! $hidden )
        {
            update_user_option(
                $user_id,
                $desc_key,
                array ( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn' )
            );
        }
        elseif ( FALSE !== ( $key = array_search( 'description', $hidden ) ) )
        {
            unset( $hidden[ $key ] );
            update_user_option( $user_id, $desc_key, $hidden );
        }
    
        return $columns;
    }