Make WordPress Core


Ignore:
Timestamp:
04/29/2010 03:43:39 AM (15 years ago)
Author:
nacin
Message:

Nav menu UI updates. props koopersmith, see #13134.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/nav-menu.php

    r14285 r14287  
    3333            '_wpnonce',
    3434        );
     35       
     36        $original_title = '';
     37        if ( 'taxonomy' == $item->type ) {
     38            $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
     39        } elseif ( 'post_type' == $item->type ) {
     40            $original_object = get_post( $item->object_id );
     41            $original_title = $original_object->post_title;
     42        }
    3543        ?>
    36         <li id="menu-item-<?php echo $item_id; ?>">
    37             <dl>
     44        <li id="menu-item-<?php echo $item_id; ?>" class="menu-item-<?php echo strtolower(esc_attr( $item->append )); ?>">
     45            <dl class="<?php
     46                if ( isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] )
     47                    echo 'menu-item-edit-active';
     48                else
     49                    echo 'menu-item-edit-inactive';
     50            ?>">
    3851                <dt>
    3952                    <span class="item-title"><?php echo esc_html( $item->title ); ?></span>
     
    6679                                );
    6780                            ?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down'); ?>">&#8595;</abbr></a>
    68                             |
    6981                        </span>
    7082                        <a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php _e('Edit Menu Item'); ?>" href="<?php
    7183                            echo add_query_arg('edit-menu-item', $item_id, remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) ) );
    72                         ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Edit'); ?></a> |
    73                         <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
    74                         echo wp_nonce_url(
    75                             add_query_arg(
    76                                 array(
    77                                     'action' => 'delete-menu-item',
    78                                     'menu-item' => $item_id,
    79                                 ),
    80                                 remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
    81                             ),
    82                             'delete-menu_item_' . $item_id
    83                         ); ?>"><?php _e('Delete'); ?></a>
     84                        ?>#menu-item-settings-<?php echo $item_id; ?>">Edit Menu Item</a>
    8485                    </span>
    8586                </dt>
     
    8788
    8889            <div class="menu-item-settings <?php
    89                 if ( isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ) :
    90                     echo ' menu-item-edit-active';
    91                 else :
    92                     echo ' menu-item-edit-inactive';
    93                 endif;
    94             ?>" id="menu-item-settings-<?php echo $item_id; ?>">
    95                 <p class="description">
     90                if ( isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] )
     91                    echo 'menu-item-edit-active';
     92                else
     93                    echo 'menu-item-edit-inactive';
     94            ?>" id="menu-item-settings-<?php echo $item_id; ?>">       
     95                <?php if( 'custom' == $item->type ) : ?>
     96                    <p class="field-url description description-wide">
     97                        <label for="edit-menu-item-url-<?php echo $item_id; ?>">
     98                            <?php _e( 'URL' ); ?><br />
     99                            <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
     100                        </label>
     101                    </p>
     102                <?php endif; ?>
     103                <p class="description description-thin">
    96104                    <label for="edit-menu-item-title-<?php echo $item_id; ?>">
    97                         <?php _e( 'Menu Title' ); ?><br />
     105                        <?php _e( 'Navigation Label' ); ?><br />
    98106                        <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
    99107                    </label>
    100108                </p>
    101                 <p class="description">
    102                     <label for="edit-menu-item-url-<?php echo $item_id; ?>">
    103                         <?php _e( 'URL' ); ?><br />
    104                         <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
    105                     </label>
    106                 </p>
    107                 <p class="description">
     109                <p class="description description-thin">
    108110                    <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
    109111                        <?php _e( 'Title Attribute' ); ?><br />
     
    111113                    </label>
    112114                </p>
    113                 <p class="description">
     115                <p class="field-link-target description description-thin">
    114116                    <label for="edit-menu-item-target-<?php echo $item_id; ?>">
    115117                        <?php _e( 'Link Target' ); ?><br />
     
    120122                    </label>
    121123                </p>
    122                 <p class="description">
     124                <p class="field-css-classes description description-thin">
    123125                    <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
    124126                        <?php _e( 'CSS Classes (optional)' ); ?><br />
     
    126128                    </label>
    127129                </p>
    128                 <p class="description">
     130                <p class="field-xfn description description-thin">
    129131                    <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
    130                         <?php _e( 'Link Relationship (XFN) (optional)' ); ?><br />
     132                        <?php _e( 'Link Relationship (XFN)' ); ?><br />
    131133                        <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
    132134                    </label>
    133135                </p>
    134                 <p class="description">
     136                <p class="field-description description description-wide">
    135137                    <label for="edit-menu-item-description-<?php echo $item_id; ?>">
    136                         <?php _e( 'Description (optional)' ); ?><br />
     138                        <?php _e( 'Description' ); ?><br />
    137139                        <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); ?></textarea>
    138140                        <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
    139141                    </label>
    140142                </p>
     143               
     144                <span class="menu-item-actions description-wide submitbox">
     145                    <?php if( 'custom' != $item->type ) : ?>
     146                        <p class="link-to-original"><?php
     147                            _e('Original ');
     148                            echo esc_html( $item->append );
     149                            echo ":"; ?>
     150                            <a href="<?php echo esc_attr( $item->url ); ?>">
     151                                <?php echo esc_html($original_title); ?>
     152                            </a>
     153                        </p>
     154                    <?php endif; ?>
     155                    <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
     156                    echo wp_nonce_url(
     157                        add_query_arg(
     158                            array(
     159                                'action' => 'delete-menu-item',
     160                                'menu-item' => $item_id,
     161                            ),
     162                            remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
     163                        ),
     164                        'delete-menu_item_' . $item_id
     165                    ); ?>"><?php _e('Remove'); ?></a> | <a class="item-close submitclose" id="close-<?php echo $item_id; ?>" href=""><?php _e('Close'); ?></a>
     166                    <input class="button-primary save-menu-item" name="save_menu_item" type="submit" value="<?php esc_attr_e('Save Menu Item'); ?>" />
     167                </span>
    141168               
    142169                <input type="hidden" name="menu-item-append[<?php echo $item_id; ?>]" value="<?php echo $item->append; ?>" />
     
    260287
    261288/**
    262  * Register nav menu metaboxes
     289 * Register nav menu metaboxes and advanced menu items
    263290 *
    264291 * @since 3.0.0
    265292 **/
    266 function wp_nav_menu_meta_boxes_setup() {
     293function wp_nav_menu_setup() {
     294    // Register meta boxes
    267295    add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
    268296    wp_nav_menu_post_type_meta_boxes();
    269297    wp_nav_menu_taxonomy_meta_boxes();
     298   
     299   
     300    // Register advanced menu items (columns)
     301    add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns');
     302   
     303    add_filter( 'columns_prefs_header', create_function( '', "return __('Show advanced menu properties');" ));
     304   
     305   
     306   
     307    // If first time editing, disable advanced items by default.
     308    if( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
     309        $user = wp_get_current_user();
     310        update_user_option($user->ID, "managenav-menuscolumnshidden",
     311            array ( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', ),
     312            true);
     313    }
    270314}
    271315
     
    374418    <div class="customlinkdiv">
    375419        <ul id="customlink-tabs" class="customlink-tabs add-menu-item-tabs">
    376             <li <?php echo ( 'create' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg('customlink-tab', 'create', remove_query_arg($removed_args)); ?>#tabs-panel-create-custom"><?php _e('Create New'); ?></a></li>
     420            <li <?php echo ( 'create' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php echo add_query_arg('customlink-tab', 'create', remove_query_arg($removed_args)); ?>#tabs-panel-create-custom"><?php _e('Create New'); ?></a></li>
    377421        </ul>
    378422
     
    391435                <label class="howto" for="custom-menu-item-name">
    392436                    <span><?php _e('Text'); ?></span>
    393                     <input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox" value="<?php echo esc_attr( __('Menu Item') ); ?>" />
     437                    <input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox label-with-default-title" title="<?php esc_attr_e('Menu Item'); ?>" />
    394438                </label>
    395439            </p>
     
    509553    <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
    510554        <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
    511             <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args)); ?>#<?php echo $post_type_name; ?>-all"><?php _e('View All'); ?></a></li>
    512             <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args)); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"><?php _e('Search'); ?></a></li>
     555            <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php echo add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args)); ?>#<?php echo $post_type_name; ?>-all"><?php _e('View All'); ?></a></li>
     556            <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php echo add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args)); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"><?php _e('Search'); ?></a></li>
    513557        </ul>
    514558
     
    665709    <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
    666710        <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
    667             <li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args)); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"><?php _e('Most Used'); ?></a></li>
    668             <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args)); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"><?php _e('Search'); ?></a></li>
    669             <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="menu-tab-link" href="<?php echo add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args)); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"><?php _e('View All'); ?></a></li>
     711            <li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php echo add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args)); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"><?php _e('Most Used'); ?></a></li>
     712            <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php echo add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args)); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"><?php _e('Search'); ?></a></li>
     713            <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>><a class="nav-tab-link" href="<?php echo add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args)); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"><?php _e('View All'); ?></a></li>
    670714        </ul>
    671715
     
    886930}
    887931
     932/**
     933 * Returns the columns for the nav menus page.
     934 *
     935 * @since 3.0.0
     936 *
     937 * @param string $menu_item_id The ID of the menu item to format.
     938 * @return string|WP_Error $output The menu formatted to edit or error object on failure.
     939 */
     940function wp_nav_menu_manage_columns() {
     941    return array(
     942        'cb' => '<input type="checkbox" />',
     943        'link-target' => __('Link Target'),
     944        'css-classes' => __('CSS Classes'),
     945        'xfn' => __('Link Relationship (XFN)'),
     946        'description' => __('Description'),
     947    );
     948}
     949
    888950?>
Note: See TracChangeset for help on using the changeset viewer.