Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
"WordPress already comes with the option to add a description to each menu item, but it is hidden by default." See: kriesi.at/archives/… –  adrian7 Jan 6 '13 at 13:31
    
adrian7, how can I show this metabox by default? –  Stanislau Ladutska Jan 6 '13 at 13:36
    
I will post an answer when I find out. –  adrian7 Jan 6 '13 at 13:42
    
Thank you, adrian7! –  Stanislau Ladutska Jan 6 '13 at 13:47
add comment

2 Answers 2

up vote 0 down vote accepted

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;
}
share|improve this answer
    
Thank you, toscho♦ ! –  Stanislau Ladutska Jan 6 '13 at 14:51
add comment

If you're looking to output the menu description here is a useful tutorial using WordPress Walker Menu class to enchance the menu Wordpress Walker Menu Tutorial

share|improve this answer
    
Thank you nackle for your answer. But I need a little different thing. I need to enable metabox in admin panel, on nav-menus screen. –  Stanislau Ladutska Jan 6 '13 at 13:23
1  
@nackle your answer is not related to the question. –  adrian7 Jan 6 '13 at 13:34
    
It may not be related the the original question, but a search on here for "nav description" brought this post as the first result. Which in turned answered the question that I came here with on how to display nav descriptions. Upvote for that. –  AndyWarren Apr 6 '13 at 15:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.